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

Get Architecting Angular Applications with Redux, RxJS, and NgRx now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.