Promise APIs
Promise APIs
Section titled “Promise APIs”Introduction
Section titled “Introduction”JavaScript provides several static methods to work with multiple promises concurrently. Each serves a different concurrency pattern.
Topics Covered
Section titled “Topics Covered”- Promise.all — Wait for all to fulfill
- Promise.race — First to settle wins
- Promise.allSettled — Wait for all, never rejects
- Promise.any — First success wins
Learning Objectives
Section titled “Learning Objectives”- Know when to use each Promise combinator
- Understand the difference between all, race, allSettled, and any
- Handle errors appropriately for each method
Summary
Section titled “Summary”| Method | Resolves | Rejects |
|---|---|---|
Promise.all | When all fulfill | When any rejects |
Promise.race | When any settles | When any settles |
Promise.allSettled | When all settle | Never |
Promise.any | When any fulfills | When all reject |