Promise

Javascript uses promises which are objects that are used to handle a single event asynchronously. Promises are eager which means that it will do whatever it is told to do when the constructor is called. Promises uses .then() to chain multiple actions.

Observable

Angular uses observables which can be compared to a stream that handles events using the callback function for each event. Unlike promises observables are lazy which means that the function is run unless it is called. Because of its lazy nature people prefer observables over promises. Observables can also be cancelled unlike promises. If the result of the observable is not needed anymore you can cancel the subscription to stop. Observables to be subscribed to in order receive the notification that the event has occurred. Inside the subscription you decide how to handle the event. After you are done with the subscription you would unsubscribe from the observable to prevent memory leaks.

Conclusion

Observables are used for a more reactive style because of its lazy nature but there is no inherent advantage it has over promises. Unlike promises observables need to be subscribed to in order to use and unsubscribed from to release resources. If your application has too many subscriptions that are not released you will run into memory leaks slowing it down. Overall when using observables you would need to pay more attention in using it compared to promises.

Hi

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store