|
Answer» Seven most common differences between PROMISES and Observables? Below are the seven most common difference between Promises and Observables in Angular 8:-
(1)Promises:-Promises always be a asynchronous. (1)Observables:-Obserables are both synchronous and asynchronous.
(2)Promises:-Promises will deal with single asynchronous event at a time. (2)Observables:-With the observables we can handle sequence of asynchronous events over a period of time.
(3)Promises:-We will get only single value in Promises. (3)Observables:-And we will get multiple VALUES in observables.
(4)Promises:-We can say promises are not LAZY and will execute soon after the creation of promises. (4)Observables:-And we can say observables are very lazy and they will not execute till we subscribe them by USING subscribe() method.
(5)Promises:-We cannot cancel the promises. (5)Observables:-We can cancel the observables by using unsubscribe() mthod. After that, they stop the listener from receiving further values.
(6)Promises:-We cannot do any operation in Promises. (6)Observables:-And with the helps of observable we can map for foreach, filter, reduce, retry and retrywhen operators.
(7)Promises:-When we say about the error promises push errors to child promises. (7)Observables:-And when when we say error in observable it will deliver errors to subscribers.
|