Oh wow, this is next level! Also TIL about for-await-of; neat. Do you have some examples of where this can be really helpful in real world code? I'm wondering when I should think to maybe reach for this instead of cobbling something else together 😃 Thanks!
Thanks, I'm glad you liked the article 😃
Generally, the async iteration is well suited for all those circumstances where consumers should have control over the flow of data.
Next time I'll show some more concrete examples thanks to async generators, but for now a good starting point to satisfy your needs surely are Node.js Readable streams. WHATWG Streams are async iterables too.
I was thinking pagination could be a use case candidate for async iteration.
const page = await pagination[Symbol.asyncIterator]().next();
Yes of course. I've already briefly mentioned it into the 'The consumer pressure problem' section 😃
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.