>Wouldn't it be wonderful if ESnext allowed you to write event loops that maintain state with block scope variables instead of all the hacks we have to resort to now?
I think this is already possible:
let event = null
while (event = await getNextEvent()) {
... // process event
}
getNextEvent() creates a promise, registers an event handler which resolves it and returns the promise.Have I misunderstood your question?