Recall & Review
beginner
What is a BehaviorSubject in Angular?
A BehaviorSubject is a special type of Observable that holds a current value and emits it immediately to new subscribers. It is often used to store and share state in Angular apps.
Click to reveal answer
beginner
How does BehaviorSubject differ from a regular Subject?
Unlike a regular Subject, a BehaviorSubject stores the latest value and emits it to new subscribers right away. Regular Subjects only emit new values after subscription.
Click to reveal answer
intermediate
Why is BehaviorSubject useful as a simple store in Angular?
Because it keeps the current state and allows components to subscribe and get the latest state immediately, making it easy to share and update data reactively.
Click to reveal answer
beginner
How do you update the value inside a BehaviorSubject?
You use the .next(newValue) method to push a new value to the BehaviorSubject, which then emits it to all subscribers.
Click to reveal answer
beginner
What happens when a new component subscribes to a BehaviorSubject?
The new subscriber immediately receives the current stored value from the BehaviorSubject, even if no new values have been emitted since it subscribed.
Click to reveal answer
What method do you use to send a new value to a BehaviorSubject?
✗ Incorrect
You use .next() to send new values to a BehaviorSubject.
What value does a new subscriber to a BehaviorSubject receive?
✗ Incorrect
BehaviorSubject immediately emits the last stored value to new subscribers.
Which of these is NOT a reason to use BehaviorSubject as a simple store?
✗ Incorrect
BehaviorSubject does not persist data automatically; it only holds and emits values in memory.
What happens if you subscribe to a regular Subject after it has emitted values?
✗ Incorrect
Regular Subjects do not replay past values to new subscribers.
Which RxJS class is best for storing and sharing a simple state with immediate access to the current value?
✗ Incorrect
BehaviorSubject stores the current value and emits it immediately to new subscribers.
Explain how BehaviorSubject works as a simple store in Angular and why it is useful.
Think about how components get and update shared data.
You got /4 concepts.
Describe the difference between BehaviorSubject and a regular Subject in Angular.
Focus on value storage and emission behavior.
You got /4 concepts.