re: Understanding Generators in ES6 Javascript VIEW POST


I understand how they work, but I still have no idea where to use a generator.


redux-sagas used a lot of generator functions


The only scenario I can think of is using an asynchronous generator in combination with the "for await ... of" loop (developer.mozilla.org/en-US/docs/W...) when not using libraries such as rxjs.


Interesting! I didnt know about for await of and I thought I had mastered async await :/


I will write another post with examples where generators come in handy


Seems people agree. Unrelated: I also hate that you can't restart a generator. Despite the initial spec saying you could.

I finally got some time, so I wrote down one example for the usage of generators, hope that you'll enjoy reading it 👉dev.to/phung_cz/canceling-promises...

code of conduct - report abuse