Promises

Promises are another useful asynchronous concept available in Angular. Conceptually, promises implement a totally different pattern. A Promise is a value that will be resolved or rejected in the future. Like the Observer pattern, they can be used to manage async programming. So, why bother to have two concepts to do the same thing? Well, the verbosity of Observer allows one thing that Promise does not: unsubscribe. The main difference that may lead to a decision about which one to use is the ability of Observable to catch many subsequent asynchronous events, while Promise can manage a single asynchronous event. To emphasise the differences between Observer and Promise, we will take the same example as before, fetching movies from ...

Get Expert Angular 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.