Promises and Observables
when an async operation completes or fails a Promise handles single event at a time. Observables emit multiple values over a period of time. Observable support passing messages between publishers and subscribers in your application. Observables have purposeful benefits over other techniques for event handling, asynchronous programming etc. Observables are declarative. Observables can do the same job of Promises and more than that. Observables have more advantage so it is preferred over Promise. Observable is cancellable using unsubscribe method whereas Promises are not cancellable but there are two possible decisions which can be made, that is reject and resolve. Operators like map, forEach, reduce are also provided in Observables. Promises don’t provide any operators. Promises gradually call the success or failed messages even if you don’t want the notification.
Comments
0 comments
Please Sign in or Create an account to Post Comments