
上QQ阅读APP看书,第一时间看更新
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