Promise States
pending, fulfilled and rejected states of Promises
We'll cover the following
Promises represent the eventual result of an asynchronous operation. They give us a way to handle asynchronous processing in a more synchronous fashion. A promise represents a value we can handle in the future, with the following guarantees:
- Promises are immutable.
- Promises are either kept or broken.
- When a promise is kept, we are guaranteed to receive a value.
- When a promise is broken, we are guaranteed to receive the reason why the promise cannot be fulfilled.
Promise States
pending
: may transition tofulfilled
orrejected
fulfilled
(kept promise): must have a valuerejected
(broken promise): must have a reason for rejecting the promise
Get hands-on with 1400+ tech skills courses.