0 votes
in JavaScript by
What are the differences between promises and observables in Javascript?

1 Answer

0 votes
by

Some of the major difference in a tabular form

PromisesObservables
Emits only a single value at a timeEmits multiple values over a period of time(stream of values ranging from 0 to multiple)
Eager in nature; they are going to be called immediatelyLazy in nature; they require subscription to be invoked
Promise is always asynchronous even though it resolved immediatelyObservable can be either synchronous or asynchronous
Doesn't provide any operatorsProvides operators such as map, forEach, filter, reduce, retry, and retryWhen etc
Cannot be canceledCanceled by using unsubscribe() method
 
...