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 and react when new data arrives, like listening to a radio station.
Click to reveal answer
beginner
How do you subscribe to an observable in Angular?
You use the
subscribe() method on the observable. This tells Angular to start listening and run your code when data comes in.Click to reveal answer
intermediate
Why should you unsubscribe from observables?
To avoid memory leaks. If you don’t stop listening when the component is gone, your app keeps using memory and can slow down or crash.
Click to reveal answer
intermediate
What is a common way to unsubscribe automatically in Angular?
Use the
takeUntil() operator with a Subject that emits when the component is destroyed, or use Angular's async pipe in templates.Click to reveal answer
intermediate
What are the three callback functions you can pass to
subscribe()?1. Next: runs when new data arrives.<br>2. Error: runs if something goes wrong.<br>3. Complete: runs when the observable finishes sending data.
Click to reveal answer
What does the
subscribe() method do in Angular?✗ Incorrect
subscribe() tells Angular to listen to the observable and run your code when data arrives.
Which operator helps automatically unsubscribe when a component is destroyed?
✗ Incorrect
takeUntil() listens until a signal (like component destruction) to stop the subscription.
What happens if you forget to unsubscribe from an observable?
✗ Incorrect
Open subscriptions keep using memory, which can slow or crash your app.
Which of these is NOT a callback you can pass to
subscribe()?✗ Incorrect
cancel is not a callback for subscribe(). The three are next, error, and complete.
What is the easiest way to handle subscriptions in Angular templates?
✗ Incorrect
The async pipe automatically subscribes and unsubscribes for you in templates.
Explain how subscribing to an observable works in Angular and why it is important to unsubscribe.
Think about listening to a radio and turning it off when done.
You got /4 concepts.
Describe two ways to manage subscriptions safely in Angular components.
One way uses code in the component, the other uses the template.
You got /3 concepts.