Observables and Behavior Subjects

  • Observable: An Observable is a stream of events or information that arrives over time. Because of this, you know that at the moment in time you receive a notification from an observable stream, the information exposed by that notification is correct for that moment in time. This flow of data is dynamic and updates in real time.

  • BehaviorSubject: A BehaviorSubject is a special kind of subject/observable. The key difference between a BehaviorSubject and a regular Observable is that a BehaviorSubject requires an initial value and emits its current value to new subscribers. This makes it useful for storing the current state of data, such as user input, form fields, UI state, etc.

Last updated

Was this helpful?