Observables vs Promises
Both Promises and Observables provide us with abstractions that help us deal with the asynchronous nature of our applications. However, there are important differences between the two:
As seen in the example above,
Observablescan define both the setup and teardown aspects of asynchronous behavior.Observablesare cancellable.Moreover,
Observablescan be retried using one of the retry operators provided by the API, such asretryandretryWhen. On the other hand,Promisesrequire the caller to have access to the original function that returned the promise in order to have a retry capability.