What is the difference between a BehaviorSubject and a regular Subject

preview_player
Показать описание
Both `BehaviorSubject` and `Subject` are a type of Observable that we can use to stream data throughout our application.

The main difference is that the `BehaviorSubject` has an initial value, and when you subscribe to it, it will give you the last value that emitted.

The regular `Subject` doesn't have an initial value, and even if it has been emitting data, when you subscribe to it you won't get any data until it emits something again.

Рекомендации по теме