Promise
A Promise
handles a single event when an asynchronous operation completes or fails.
There are Promise
libraries out there that allow cancellation, but ES6 Promise has not done so far. At least not that I have found yet.
Observable
A Observable
is a data flow ( Stream
in other languages) and allows to pass zero or more events where a callback is invoked for each event.
Often Observable
is preferred before Promise
because it provides the characteristics of Promise
and much more. With Observable
it does not matter if you want to handle 0, 1 or several events. You can use the same API in each case.
Observable
also has the advantage over Promise
that can be canceled. If the result of an HTTP request to a server or some other expensive asynchronous operation is no longer necessary, the Suscription
of a Observable
allows canceling the subscription, while a Promise
will eventually call the success or rejection callback, Even if you do not need it anymore.
Observable
provides operators such as map (), forEach (), reduce (), ... similar to an array
There are also powerful operators like retry (), or replay (), which are often very useful.
In my case, when I started using Observable
, I completely forgot about Promise
.
I hope the explanation is clear, otherwise, do not hesitate to ask everything you need.