Async generators in standard library

I’m a bit curious as to why Generators.observe() and Generators.queue() (and consequently Generators.input()) return synchronous generators yielding promises, and not real asynchronous generators (with the [Symbol.asyncIterator]() method) ? Using the latter would seem more consistent to me as they were specifically designed to represent asynchronous data sources.

2 Likes

These implementations predate support for async iterators in browsers and changing them would not be backwards compatible. That said, we could introduce new Generators.asyncInput and Generators.asyncObserve methods.

OK thanks Mike.

Just published an example implementation of such a Generators.asyncObserve() in

3 Likes