How is observable different from promise?
Observables | Promises |
---|---|
These are used for streams of events over time. | It is able to handle only one event. |
It supports operators such as map, filter, reduces, etc., and is cancel-able and retry-able. | It is not easy to handle and returns a single value. |
It provides chaining and subscriptions for handling complex applications. | It uses only the .then() clause. |
Here the subscribe method is used for a centralized and predictable error handling. | It pushes the errors to the child's promises. |
Note: This node js interview questions have been created by seasoned Node.js experts. It shall help you to answer some of the most frequently asked questions during a job interview.
BY Best Interview Question ON 29 Jun 2020