Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Syncing Async

Syncing Async

I bet you think “callback hell” is about function nesting and levels of indentation. Not so much. I bet you’ve heard that Promises replace callbacks. Nope.

We need some clarity on what async flow control is all about in JavaScript. We’ll explore the perils of “Inversion of Control”, and see just what hell that leads us to. Then we’ll talk about promises as “continuation events” for function calls, and abstractions on top of promises that clean up our code. Finally, we’ll see how generators give us synchronous-looking async, and even how we can create cooperative concurrency with coroutines.

Yield those confused async notions and control your flow. I promise we’ll get your thoughts in order.

Kyle Simpson

October 16, 2015

More Decks by Kyle Simpson

Other Decks in Programming


  1. trust: 1. not too early 2. not too late 3.

    not too many times 4. not too few times 5. no lost context 6. no swallowed errors ...
  2. promises: 1. only resolved once 2. either success OR error

    3. messages passed/kept 4. exceptions become errors 5. immutable once resolved