This question already has an answer here:
- What happens when promise is yielded in javascript? 2 answers
I am struggling to understand how to use generator functions and iterators to achieve various design options for a library I am thinking about writing.
Having got past the simple generator functions, I am now struggling with the examples out there on the internet showing how to integrate generators with Promises.
One problem is all the articles are written before the ES2015 spec on Promises was available and they all use 3 party libraries which I don't know what the nuances are.
So the question I don't really understand is if you yield and the generator function calls .next(Promise returning function) does the statements beyond the yield continue as soon as the .next function is called, or when the returned promise resolves. The examples seem to imply that it waits until the Promise resolves, but I don't see the logic of why.