In Angular, as soon as we make a promise, the execution takes place, but this is not the case with observables because they are lazy. It means nothing happens until a subscription is made.
Promise | Observable |
---|---|
It emits a single value. | It emits multiple values over a period of time. |
Not Lazy | Lazy. An observable is not called until we subscribe to the observable. |
We can not cancel it. | We can cancel it by using the unsubscribe() method. |
Observable provides operators like map, forEach, filter, reduce, retry, retryWhen, etc. |
Submitted questions and answers are subject to review and editing, and may or may not be selected for posting, at the sole discretion of w3Sniff.
Get Started
Comments
Leave a Comment