News for hackers. Stuff that matters.
Re:Internals of Async / Await in JavaScript by emadda on Saturday September 02, 2023 @04:24PM (#37365194)
A nice use of async generators is when you have an API with paginated results.

The generator function keeps track of the current page.

This allows you to use a `for await` loop which is quite concise.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

You can do it without generator functions, but generator functions allows the caller to not have to know about the underlying pagination API.

There are no comments on this comment yet.