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

Warping Time with Async/Await

Warping Time with Async/Await

The JS world is a constant surprise. Just look at the recent years and you'll see why. The language itself is maturing and the angles from which we look at it are becoming more and more diverse. We've arrived from 10-year release cycles to yearly feature upgrades. ES2017 is upon us and together with it, a new tool that gives us time-warping superpowers: Async/Await. Come learn (almost) all there is to know about it and how you can start using it today. It's going to be fun!

Cassian LUP

June 08, 2017
Tweet

More Decks by Cassian LUP

Other Decks in Programming

Transcript

  1. JS History (there’s hope) 1995 2005 2015 JS ES5 ES6

    ES2017 Page Load AJAX Promises Async/ Await You are here.
  2. 1. jscodeshift, Facebook tool https://github.com/facebook/jscodeshift 2. Based on ASTs https://astexplorer.net

    3. Check out js-codemod https://github.com/cpojer/js-codemod Demo Explained: Async / Await codeshift
  3. 1. Delayed execution 2. Promise.all() for making awaited HTTP calls

    run concurrently 3. Non-promises can also be awaited: await calls Promise.resolve with the value itself. Async / Await Gotchas
  4. 1. History: Page Load → AJAX → Promises → Async

    / Await 2. Syntactic sugar making promises seem sync (promise pitfalls still apply) 3. Shared state (no more isolated scopes) 4. async functions return Promises 5. try-catch is now possible 6. You can await anything 7. node.js >= 7.6.0, browsers friendly Recap
  5. • https://tc39.github.io/ecmascript-asyncawait/ • https://github.com/tc39/ecmascript-asyncawait • https://ponyfoo.com/articles/understanding-javascript-async-await • https://dzone.com/articles/unit-testing-with-jasmine-and-asyncawait • https://applyhead.com/javascript-callback-promise-async-await/

    • http://thecodebarbarian.com/80-20-guide-to-async-await-in-node.js.html • http://www.jstips.co/en/javascript/improving-your-async-functions-with-webworkers/ • http://www.2ality.com/2016/02/async-functions.html • https://zeit.co/blog/async-and-await • https://node.university/blog/498412/es7-es8#async-functions Resources