Recall & Review
beginner
What is an Observable in Angular?
An Observable is a way to handle asynchronous data streams. It lets you watch for data changes over time and react when new data arrives.
Click to reveal answer
beginner
How do you create a simple Observable that emits values in Angular?
You use the
new Observable() constructor and provide a function that calls observer.next() to send values.Click to reveal answer
beginner
What does the
subscribe() method do on an Observable?It starts listening to the Observable. When the Observable emits data, the
subscribe() callback runs to handle that data.Click to reveal answer
intermediate
Name two common ways to create Observables in Angular besides using the constructor.
You can use creation functions like
of() to emit fixed values or fromEvent() to create Observables from DOM events.Click to reveal answer
intermediate
Why is it important to unsubscribe from Observables in Angular?
To avoid memory leaks. If you don’t unsubscribe, the Observable keeps running and can cause your app to slow down or crash.
Click to reveal answer
Which method do you use to start receiving data from an Observable?
✗ Incorrect
The
subscribe() method is used to listen to data emitted by an Observable.What does the
of() function do in Angular Observables?✗ Incorrect
of() creates an Observable that emits the values you pass to it immediately.Which RxJS function creates an Observable from a DOM event?
✗ Incorrect
fromEvent() creates an Observable that emits events from a DOM element.What happens if you don’t unsubscribe from an Observable in Angular?
✗ Incorrect
Not unsubscribing can cause memory leaks because the Observable keeps running in the background.
Which of these is NOT a way to create an Observable?
✗ Incorrect
subscribe() is used to listen to an Observable, not to create one.Explain how to create a basic Observable in Angular and how to listen to its data.
Think about how you tell a friend to watch for updates and how you send those updates.
You got /3 concepts.
Why is unsubscribing from Observables important in Angular apps?
Imagine leaving a faucet running when you don’t need water.
You got /3 concepts.