In the previous chapter, we learned about generators: how they work, and one or two things they can be useful for. We ended with a demonstration of building a multitasking system. In particular, we looked at how to use generators as interruptible functions. Other programming languages call this kind of function a coroutine (short for cooperative routine ), because it cooperates to allow for multitasking.
In the grand scheme of things, promises come before coroutines . They’re slightly harder to understand, though. They also don’t resolve (if you’ll pardon the pun) ...