In the last two episodes, I've shown you the basics of working with generators as iterators and then how generators really work behind the scenes. It's been an interesting if not difficult journey to get here. The results, though, are a much better understanding of generators than I had expected.
But we're not done, yet! Back in episode 90, I wanted to try and work on some async code using generators and I couldn't figure it out. In this episode – the third and final episode on ES6 generators – I'll cover that subject, finally. I'll show you how to build a wrapper function around a method that takes a callback and then use a combination of ES6 Promises and Generators to create code that looks synchronous but still run asynchronously!
Generators, it seems, are powerful tool with a myriad of techniques that can be used. Join me for this final look at generators, and see what it takes to turn your asynchronous callback laden functions into a series of “yield” statements that look synchronous.