Behavior and Replay Subjects
We explore two types of Subjects that buffer emitted values for Observers that subscribe at a later point in time.
We'll cover the following...
Behavior Subject
BehaviorSubject
is a special type of Subject that buffers the latest emitted value and pushes that value to every new Observer that subscribes to it. As simple as that.
The following code illustrates a simple implementation of BehaviorSubject
, which must be initialized with a default value in order to fulfill its purpose.
In a group chat room, every new user can be greeted with a default Welcome message. After some chit chat between the initial users, someone who is late to the party always ...