What are the differences between observables & promises?
Answer / Arman Awasthi
Observables and Promises are both used for handling asynchronous operations in JavaScript, but they differ in a few key ways:
1. Observables are reactive, allowing you to react to multiple events (like repeated data emissions or errors) over time, while Promises are synchronous, representing a single value that will be resolved at some point in the future.
2. Observables can be chained with operators like map(), filter(), and reduce() to perform complex operations on streams of data. Promises do not have similar built-in support for chaining.
3. Observables use a subscription model, where you subscribe to an observable to start receiving its emissions. Promises use a then() method for handling the resolved value or caught errors.
| Is This Answer Correct ? | 0 Yes | 0 No |
What do you know about internationalization?
What is interceptor in angular?
How would you use a route guard?
What is ng-model in angularjs?
What are the symbols used in one way and two ways data binding?
Why use node.js?
Is wordpress a framework?
What's new features in angular 5?
Which of the following directive is used to initialize an angular app?
What is difference between http and httpclient in angular?
Explain ng-show directive angularjs?
Explain The Directives Ng-If, Ng-Switch, And Ng-Repeat?