# Observables vs Promises

<https://stackoverflow.com/a/37365955>

**Promise** can handle only a single time when an async operation is completed (either success or error)

Note: There are Promise libraries out there that support cancellation, but ES6 Promise doesn't so far.

&#x20;**Observable**

An Observable , like explained in previous topic, can handle a stream of events happening over time to call the callback(*next*, *error*, *complete* functions) each time the event happens in the series.

*Observable* provides some bonus features over *Promise*. With Observable you can handle an event zero, single or multiple times. You can utilize the same API in each case.

Observable also has the advantage over Promise to be cancelable. If the result of an HTTP request to a server or some other expensive async operation isn't needed anymore, the Subscription of an Observable allows to cancel the subscription, while a Promise will eventually call the success or failed callback even when you don't need the notification or the result it provides anymore.

Observable provides operators like map, forEach, reduce, ... similar to an array, to customize the incoming data.

It also provides some very useful operators like retry(), or replay(), ... that are often quite handy.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bharat-tiwari.gitbook.io/our-tech-journal/angular-4/observables-vs-promises.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
