RxJS Subjects
Let's explore Subjects, their types, and how we can use these in different scenarios.
What is a Subject?
A Subject Observable is a special type of Observable which is multicast, instead of unicast like the Observables we have been looking at.
When an Observable creates a connection to an Observer, it wires up the event handlers (next, complete, and error), and then sends data to that Observer. Each Observer that is connected to the Observable is getting its own set of data. Multicasting is where one Observable sends the same data to multiple Observers. It is casting out its stream of data to all the Observers that are subscribed, and they all get the same data.
A good way to think of a Subject Observable is as an EventEmitter (which we discussed in the Components, Templates, and Forms chapter). This is the way of ...