Login
Remember
Register
Ask a Question
What are the differences between promises and observables in Javascript?
0
votes
asked
Oct 24, 2023
in
JavaScript
by
DavidAnderson
What are the differences between promises and observables in Javascript?
javascript-interview-questions-answers
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
Oct 24, 2023
by
DavidAnderson
Some of the major difference in a tabular form
Promises
Observables
Emits only a single value at a time
Emits multiple values over a period of time(stream of values ranging from 0 to multiple)
Eager in nature; they are going to be called immediately
Lazy in nature; they require subscription to be invoked
Promise is always asynchronous even though it resolved immediately
Observable can be either synchronous or asynchronous
Doesn't provide any operators
Provides operators such as map, forEach, filter, reduce, retry, and retryWhen etc
Cannot be canceled
Canceled by using unsubscribe() method
...