Writing Async Functions
Every async function in JavaScript is built on some other async function(s). Itâs async functions all the way down (to native code)!
The converse is also true: any function that uses an async function has to provide the result of that operation in an async way. As we learned from âBlocking the Threadâ, JavaScript doesnât provide a mechanism for preventing a function from returning until an async operation has finished. In fact, until the function returns, no async events will fire.
In this section, weâll look at some common patterns in async function design. Weâll see that functions can be mercurial, deciding to be async only some of the time. But first, letâs define exactly what an async function is. ...
Get Async JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.