Asynchronous JavaScript with async/await
I'm super excited to present Asynchronous JavaScript with async/await, my first egghead.io course!
It consists of 8 concise videos with a total length of 18 minutes. Grab a beverage of your choice, lean back, and learn all about ES2017's asynchronous functions:
- Write an Asynchronous Function with
async
/await
: This lesson introduces the ES2017async
andawait
keywords. It shows how to write a short asynchronous function that makes an HTTP request and parses the response. - Call an Asynchronous Function in a Promise Chain: In this lesson, we’re exploring how asynchronous functions can be seamlessly called within a promise chain — just like any other function that returns a promise.
- Convert Any Function into an Asynchronous Function: Any function can be made asynchronous, including function expressions, arrow functions, and methods. This lesson shows the syntax for each of the function types.
- Handle Errors in Asynchronous Functions: This lesson shows how regular control flow statements such as
try
/catch
blocks can be used to properly handle errors in asynchronous functions. Oftentimes, the resulting code is easier to read than complex promise chains with.catch()
methods. - Await Multiple Promises Sequentially or Concurrently: You can await multiple promises either sequentially or concurrently, depending on where you put the
await
operators. This lesson shows both approaches and compares the performance characteristics. - Await Multiple Promises Concurrently with
Promise.all()
: Oftentimes, you want to kick off multiple promises in parallel rather than awaiting them in sequence. This lesson explains how that can be achieved in a readable manner usingawait
, thePromise.all()
method, and destructuring assignment. - Use the
await
Operator with Any Thenable: Theawait
operator is not restricted to ES2015 promises. It can be used to await any thenable — that is, any object with a.then()
method. This lesson illustrates how to await promises that have been created using a promise library. - Iterate Asynchronously with the
for
-await
-of
Loop: We finish the course by looking at asynchronous iterators, a generic data access protocol for asynchronous data sources. This asynchronous iteration scheme is built on top of a newfor
-await
-of
loop and async generator functions.