Tag
async
Published articles tagged async.
Async iterators and for await..of
Async iterables produce values that may arrive after await, which fits streams, paginated APIs, and backpressure-friendly pipelines. This chapter covers Symbol.asyncIterator, async generators, and for await..of consumption.
Async/await in JavaScript
Async functions always return a Promise, and await pauses until a Promise settles—giving sequential async code without nested then chains. This chapter covers syntax, parallel awaits, and error handling patterns.
Callbacks and timers
Host APIs still expose completion handlers as functions you pass in. This chapter covers callback conventions, setTimeout and setInterval, and why nested callbacks led to promises and async/await.
Cancellation with AbortController
Promises do not cancel themselves; AbortController provides a standard signal for fetch, streams, and your own async tasks. This chapter covers signals, abort reasons, and cleaning up listeners when work is no longer needed.
Promises in JavaScript
A Promise represents one eventual result—fulfilled or rejected—and gives shared combinators for sequencing and racing async work. This chapter covers construction, then/catch/finally, Promise.all, and common pitfalls.
The event loop, tasks, and microtasks
The event loop is what turns one thread into a responsive program: it picks a task, runs it to completion, drains the microtasks, and gives the browser a chance to render. This chapter walks one turn of the loop, predicts the output of ordering puzzles from first principles, and shows where Node's loop differs.
Async generator in TypeScript
TypeScript types async generators with AsyncGenerator, AsyncIterable, and AsyncIterator so yield and for await..of stay checked at compile time. This page covers return types, TReturn/TNext, and typing consumers.
Error handling with async/await in TypeScript
TypeScript narrows results when you separate success and failure with typed tuples or Result-like helpers, and it types catch clauses under useUnknownInCatchVariables. This page focuses on typing async error paths—not on try/catch mechanics.
Asynchronous data handling
JavaScript runs user code on one thread per realm, yet programs must respond to timers, network I/O, and user input without blocking. This overview maps callbacks, promises, async/await, cancellation, and observables—and when each fits.
Observables in JavaScript
Observables push many values over time and support unsubscribe, which suits events and live streams but adds weight promises avoid. This comparison chapter covers push versus pull, RxJS basics, and when to stay with promises.