Is it possible to write an asynchronous generator like the following:
function gen() {
return async function * () {
yield await ...
yield await ...
yield await ...
}()
}
So one can use it like this, for example:
for (let val of await gen()) {
...
}
I can't really work out the semantics of this construction, how are async generators used in loops?
Until the async iteration proposal is complete, you could take a page from the Redux-saga book (like Cory Danielson mentioned) and have an adapter function that does all the async/await stuff.