Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

From Callback Hell to Async Heaven - Promises!

1,499 views

Published on

Come with me as I lead you from the pit of callback despair, up to the purgatorio of promises, and finishes in async heaven - using generators and yields to make async code look like sync code

Published in: Technology
  • Be the first to comment

From Callback Hell to Async Heaven - Promises!

  1. 1. From Callback Hell to Async Heaven – Promises! A Play in Three Acts: Inferno, Purgatorio, and Paradiso
  2. 2. Act I: Inferno THE ROAD TO HELL IS PAVED WITH GOOD INTENTIONS
  3. 3. Our Journey Begins
  4. 4. Focusing on the Main Code
  5. 5. The Good and the Bad Simple Readable Debuggable Holds the Thread! Not Async!
  6. 6. SO HOW DO WE RELEASE THE THREAD? Callbacks!
  7. 7. Good Intentions CALLBACKS
  8. 8. Looks Good…
  9. 9. Doesn’t Look to Bad…
  10. 10. The Pyramid of Doom!
  11. 11. Our Code, In Hell
  12. 12. In Callback Hell, There are no Loops!
  13. 13. Act II: Purgatorio BUT I PROMISE – IT GETS BETTER
  14. 14. Promises Instead of Callbacks
  15. 15. Chaining Promises
  16. 16. Easy Concurrency ES6!
  17. 17. So How Do We Write promisedOpen?
  18. 18. Yes, But How do Promises Work? • I don’t know • And if I try to understand, my head hurts • I just learn to accept it
  19. 19. Generalizing promisedOpen Across All Node Functions ES6!
  20. 20. So Where Does This Take Us? Ugh… Still no loop
  21. 21. Act III: Paradiso PROMISES MUST BE KEPT – ONWARD TO ASYNC HEAVEN!
  22. 22. BUT LET’S YIELD TO A LITTLE DETOUR
  23. 23. Generator Functions
  24. 24. Iterator Protocol
  25. 25. We could have done it like this… ES6!
  26. 26. But the ES6 compiler does it like this…
  27. 27. Bi-Directional Protocol
  28. 28. THIS IS WHERE IT BECOMES MIND-BOGGLING
  29. 29. Can We Fulfill The Promise?
  30. 30. Sure!
  31. 31. So What About This?
  32. 32. No Problem!
  33. 33. Let’s Generalize
  34. 34. And… Async Heaven!
  35. 35. Compare
  36. 36. The Future
  37. 37. Epilogue SO…
  38. 38. From Callback Hell
  39. 39. To Async Heaven
  40. 40. Our Journey is Complete Thank You https://github.com/giltayar/callback-to-async- presentation

×