0
0
Angularframework~5 mins

Observable vs Promise mental model in Angular - Quick Revision & Key Differences

Choose your learning style9 modes available
Recall & Review
beginner
What is an Observable in Angular?
An Observable is a way to handle multiple asynchronous events over time. It can emit many values, and you can listen to these values as they come.
Click to reveal answer
beginner
What is a Promise in Angular?
A Promise handles a single asynchronous event. It either resolves with a value or rejects with an error, but only once.
Click to reveal answer
intermediate
How does an Observable differ from a Promise in terms of values emitted?
An Observable can emit multiple values over time, while a Promise emits only one value or error once.
Click to reveal answer
intermediate
Can you cancel an Observable subscription? What about a Promise?
Yes, you can cancel an Observable subscription to stop receiving values. Promises cannot be cancelled once started.
Click to reveal answer
intermediate
Why might you choose an Observable over a Promise in Angular?
Choose Observable when you need to handle multiple values, streams of data, or want to cancel the operation. Use Promise for a single async result.
Click to reveal answer
Which of these can emit multiple values over time?
APromise
BObservable
CBoth Observable and Promise
DNeither
Can you cancel a Promise once it starts?
ANo, Promises cannot be cancelled
BOnly if it is resolved
COnly in Angular
DYes, easily
What does a Promise return when it completes successfully?
AA single value
BMultiple values
CAn Observable
DNothing
Which is better for handling streams of data in Angular?
APromise
BBoth are equally good
CObservable
DNeither
How do you stop receiving data from an Observable?
ABy resolving the Promise
BBy calling .cancel() on the Observable
CYou cannot stop it
DBy unsubscribing from the Observable
Explain in your own words the main difference between an Observable and a Promise.
Think about how many values each can handle and if you can stop them.
You got /4 concepts.
    Describe a situation in Angular where using an Observable is better than a Promise.
    Consider when data comes in many pieces over time.
    You got /4 concepts.