But they are not just keywords that magically make something async work with the rest of the program. It changes how the function work and that can lead to errors without proper understanding.
From this book, you'll learn the basics of async/await and you'll be familiar with the common problems with it and their solutions.
Want a sneak peek? Sign up for free chapters here:
Instead, it has Promises and async/await.
But callbacks are the past now as they lead to a cluttered program structure. Instead, Promises and now async/await is the mainstream way to handle asynchronous results.
The async/await addition to the language makes using async functions a lot easier. You no longer need to interpret complicated Promise chains and use an unfamiliar error handling scheme. The complexity is hidden behind two keywords.
This book helps you understand how async functions works and how to use them. And with the more advanced patterns, no async/await problem will be beyond you. You'll learn:
Getting started with async/await
How to use the Promise
The benefits of Promises
The await keyword
Async function examples
The Promise constructor
Error callback in the Promise constructor
Rejecting a Promise
Error propagation in Promise chains
Parallel and sequential processing
Parallel processing with Promise.all
Errors in Promise.all
Returning multiple values
Convert between Promises and callbacks
Convert callbacks to Promises
Convert Promises to callbacks
The async serializer pattern
Why await is not a solution
A general-purpose solution
The async disposer pattern
Paginating with async generators
A solution with async generators
Breaking it down
Making it generic
Using async functions with postMessage
Collection processing with async functions
Async for iteration
Async functions with reduce
await memo last
await memo first
When parallelism matters
Async functions with map
Async functions with forEach
Controlling the timing
Waiting for finish
Async functions with filter
Async filter with map
Async filter with reduce
Async functions with some/every
Using an async filter
Not propagating errors
Missing await in try..catch
Not checking the return value
Not closing resources in case of a rejection
Using both the rejection and resolve handlers in one then function
Not waiting for an async forEach
About the author
I'm a software developer focusing mostly on cloud computing and web technologies. I'm especially interested in how to handle edge cases to end up with dependable software.
One of my main focus is security and how each part affects the whole system. I'm an AWS-certified security specialist.
The book is available from these stores: