What is the difference between Promises and Observables

0 votes
May 23, 2022 in Angular by Kichu
• 19,040 points
566 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Promise

In the event that an async operation succeeds or fails, a Promise handles a single event. Although ES6 Promise does not yet support cancellation, there are promise libraries that do.

Observable

Similar to a stream (in many programming languages), an observable permits the passing of zero or more events, with the callback being triggered by each event.

Because it offers Promise's characteristics and more, Observable is frequently chosen over Promise. Observable allows you to handle 0 events, 1 event, or numerous events. In each situation, you can use the same API. 

Being cancellable is another advantage that Observable has over Promise. The Subscription of an Observable allows you to cancel the subscription if the outcome of an HTTP request to a server or another expensive async operation is no longer required, whereas a Promise will eventually call the success or failed callback even if you no longer require the notification or the result it provides.

A Promise begins right away, but an Observable doesn't begin until you subscribe to it. Due to this, Observables are referred to as lazy.

I hope this helps you understand the difference between them.

answered Jun 28, 2022 by narikkadan
• 63,600 points

edited Mar 5

Related Questions In Angular

0 votes
1 answer

What is the difference between Call back transclusion function and no call back transclusion function?

Hey,    There is no difference between clone linking and ...READ MORE

answered Feb 5, 2020 in Angular by Niroj
• 82,840 points
744 views
0 votes
1 answer

What is the difference between Routing using resolve and without using it?

There is not much difference between routing ...READ MORE

answered Feb 10, 2020 in Angular by anonymous
• 82,840 points
933 views
0 votes
0 answers

What is the difference between dependency injection and service in Angular?

Can you explain with an example that ...READ MORE

Mar 3 in Angular by Nidhi
• 12,580 points
44 views
0 votes
0 answers

What’s the difference between Observables and Promises?

With the help of an example, can ...READ MORE

Mar 3 in Angular by Nidhi
• 12,580 points
61 views
0 votes
0 answers

What is the difference between debounceTime and debounce?

Can you tell me what the difference ...READ MORE

Mar 5 in Angular by Nidhi
• 12,580 points
82 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Error TS1005: ';' expected. TypeScript for First Build error rxjs inside node_modules

 I investigated that rxjs released a new version: 6.4.0. And ...READ MORE

answered Jun 10, 2022 in TypeSript by Nina
• 3,060 points
3,178 views
+1 vote
8 answers

How can I implement process.env in Angular 5 environment?

Users do not have access to process.env ...READ MORE

answered Apr 3, 2018 in DevOps & Agile by DareDev
• 6,890 points
13,520 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP