bluehost-banner
What is the Difference Between Promises and Observables?

What is the Difference Between Promises and Observables?

In this article, we will see What is the Difference Between Promises and Observables.

What is Promise?

A promise is a native feature of JavaScript that was introduced in ES6.

This indicates that all current browsers natively support this functionality without the need for an external library or plugin.

What is Observable?

An Observable is not a part of JavaScript's core functionality. It is made available through a third-party library named RXJS.

Single VS Multi Values

A promise can emit a single value over a period of time.

An Observable can emit multiple values over a period of time.

Lazy VS Non-Lazy

A Promise is not lazy in nature. A promise will be executed even if there is no then statement chained to that promise.

An Observable is lazy in nature, it won't run until there is a subscription for that observable.

If there is no subscription for an observable, the observable will not run.

Cancel VS Non-Cancel

A promise is not cancellable by default

An Observable can be cacellable, we can cancel an obserable any time by calling the unsubscibe method.

Chainning Methods

A Promise has chaining methods as then(), catch() or finally()

An Obserbale has the option of chaiing with many functions like subscibe, map, filter, reduce,forEach, etc...

Subscribe to our Newsletter

Stay up to date! Get all the latest posts delivered straight to your inbox.

If You Appreciate What We Do Here On TutsCoder, You Should Consider:

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Leave a Comment