DEV Community

Discussion on: Easy Introduction to JavaScript Generators

Collapse
 
misterhtmlcss profile image
Roger K. • Edited

John great article. I think you should do another one, but cover Symbols in the next one and then relate it to this one, do it gives a wider range of examples and comparables for us learner's.

I've been coding for three years and have found Generators and Symbols to be very hard to understand. Even after your article which I admit did greatly improved my understanding, but still I could use more and Symbols would be a great addition arrive you do refer to them in this article often.

Thank you for sharing it.

Collapse
 
aumayeung profile image
John Au-Yeung

Hi Roger,

Thanks so much for reading. Symbols are nothing but primitive values that are used for identifiers for functions.

Generators let us control how to loop through things. It's especially useful if we want to return an indeterminate collection of things in a controlled way.

Collapse
 
misterhtmlcss profile image
Roger K.

I was thinking of using a Generator to create that continuous loading effect that I've seen on websites like Facebook or pagination too. Would these be good usecases?

Thread Thread
 
aumayeung profile image
John Au-Yeung

You can use async generators to get data for infinite scrolling.

Probably don't need generators for pagination as much since you're overwriting existing data.

Thread Thread
 
misterhtmlcss profile image
Roger K.

True on that point and awesome to hear that it's a good solution for the first point. Still trying to get my head around good use cases, because it's just not obvious to me when I first, second and 10th time heard about them.

Thanks for your support and feedback!