BehaviorSubject
BehaviorSubject is a specialized subject in reactive programming that combines the capabilities of an observer and an observable with an added memory of the latest value. It stores the most recent value emitted and immediately provides that value to any new subscriber. When creating a BehaviorSubject, you must supply an initial value; this value becomes the current value until a new one is emitted.
On subscription, a BehaviorSubject immediately emits its current value to the subscriber, then continues to emit
Common use cases include representing state that changes over time and should be observable by multiple parts
Compared with ReplaySubject, BehaviorSubject stores only the latest value rather than buffering multiple values. This makes