September 2018
Intermediate to advanced
302 pages
7h 17m
English
We will also need to know how to use generators (for instance, for Redux Saga), so we should get fluent in writing them. It turns out they can act like a factory for the iterators that we have learned already.
A quick recap on generators—they are functions with * and yield operators within their scope, such as, function* minGenExample() { yield "a"; }. Such functions execute until the yield keyword is encountered. Then, the function returns with the yield value. Functions can have many yields, and on their first call, return Generator. Such a generator is iterable. Look at the following:
const a = function* gen() { yield "a"; };console.log(a.prototype)// Generator {}
We can now use this knowledge ...
Read now
Unlock full access