Back to articles
Promises, Batching, AbortController, and How the Web Actually Works
How-ToSystems

Promises, Batching, AbortController, and How the Web Actually Works

via Dev.toJalaj Bankar

A session that fills in a lot of gaps. Some advanced Promise patterns, a React performance secret most beginners don't know about, and then a mental model for HTTP and APIs that's worth reading twice. .then() and .finally() Are Full Functions — Use Them That Way A common mistake is treating .then() like it can only do one thing. It's a full function — you can declare variables, write logic, run conditions, all of it: Promise.allSettled([fetchConfig, fetchColor]) .then((results) => { const configResult = results[0].status === 'fulfilled' ? results[0].value : defaultConfig; const colorResult = results[1].status === 'fulfilled' ? results[1].value : '#FFFFFF'; }) Promise.allSettled() waits for all promises to finish — whether they resolved or rejected — and gives you a results array where each item tells you the status and value. No promise getting rejected silently breaks everything else. You handle each one individually. The Loader and allSettled Are Best Friends Think about it — a loadi

Continue reading on Dev.to

Opens in a new tab

Read Full Article
2 views

Related Articles