- Architecting Angular Applications with Redux,RxJS,and NgRx
- Christoffer Noring
- 88字
- 2021-08-27 19:56:23
Promises
Promises came about as a response to the callback hell problem described in the previous section. They have quite a long history, stretching back to the early 80s, when the legendary Barbara Liskov coined the term Promise. The idea of a Promise is to flatten out async code. A promise is said to have the following states:
- Pending: This means it has not yet been decided or that the data is not available yet
- Fulfilled: The data has come back
- Rejected: An error happened during the operation