Is there any case, where Promise is more powerful as compare to observable? I know a lot of benefits of observables over promises. But Is there any case, I should use only promi
An observable does everything that a promise does and more. It can always be switched to a promise with toPromise()
method in case a promise is expected.
An observable must be chosen over a promise if
Observable.from(...)
safety structure to unify observables and promisesAn observable may be chosen over a promise if the code where it's used uses observables exclusively.
A promise must be chosen over an observable if API that consumes it expects a promise and doesn't use Observable.from(...)
safety structure.
A promise may be chosen over an observable if
async
functions)let observable = ...; observable.subscribe(...); return observable
(this also requires multiple subscriptions to be tracked in case an observable is cancellable)