Escape Callback Hell and Enter Callback Heaven with Async/Await

Escape Callback Hell and Enter Callback Heaven with Async/Await

JavaScript relies heavily on callbacks for async functions which leads to the infamous 'callback hell'. ES7 is proposing the use of async/await to avoid this. Node.js has already implemented it in version 7.6. I will show you how you can escape from callback hell and reach callback heaven with async await.

Da526e4b5901b3a2759cf234285c6488?s=128

Jennifer Bland

September 21, 2017
Tweet

Transcript

  1. 4.

    The only thing that maters in software is the experience

    of the user Change How I/O Is Handled
  2. 7.

    Node.js Design Goals No function should direct perform I/O To

    receive info from disk, network or other process, there must be a callback Stream everything; never force the buffering of data Have built-in support for important protocols
  3. 12.
  4. 13.
  5. 15.

    z

  6. 16.

    Async Await Async - declares an asynchronous function Automatically transforms

    a regular function into a Promise When called async functions resolve with whatever is returned in their body Async functions enable the use of await
  7. 17.

    Async Await Await - pauses the execution of async functions

    When placed in front of a Promise call, await forces the rest of the code to wait until that Promise finishes and returns a result Await works only with Promises, it does not work with callbacks Await can only be used inside async functions