The RxJs Subject
Sometimes an Observable lacks what you need to get the job done, one of those needs might be the ability to multicast to many observers, this is one of the benefits of using a Subject. A Subject is an Observable, you can do anything with a Subject that you can with an Observable, you can, of course, subscribe to it, you can create a pipe of operators, and you can unsubscribe from one. Now, where Subject differs is that it is also an Observer, that is to say you can call next, error and complete on it as well, this means you can have multiple listeners/observers subscribe to the Subject, and then you can use the next function to pass an event of your choosing to each of their observers. Interestingly the call to subscribe on a Subject is no different to that of an Observable to the Observer but internally all this does is add that observer to a list of observers that it needs to cast its emits to. From this brief description, I hope you have many ideas on how you could use a Sub