List common use cases for generator functions in JavaScript

🦁 Yvonnick FRIN - Nov 8 '19 - - Dev Community

Hey 👋,

Recently, I finally found a use case for generator functions in JavaScript. But, it was quite particular. I wrote a cli that extracts information from GitHub.

I wanted to split the fetching logic from what I do with it to make it more reusable. Due to rate limit imposed by the GitHub API I had to make multiple calls to get all data I need. Each time, I get a result I want to send it to the caller so It can do something with it. To achieve it I used a pattern called Inversion of control. Generator functions fits well with this pattern. You can see my usage of it here.

I was wondering if it exists more common use cases for generator functions ?

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player