Behaviour Subject is one of the useful features in rxjs which comes pre installed in angular 9+
What is a Subject?
A RxJS Subject is a special type of Observable that allows values to be multicasted(means one observable can be used by multiple / all components) to many Observers. While plain Observables are unicast (each subscribed Observer owns an independent execution of the Observable), Subjects are multicast.
How to use?
And then utilize this observable in other components.
Use:
- To use any data in different components and just store it once and use everywhere in the angular project. Drawback:
- This sometimes gives old, unexpected values when used with APIs. So, when working with API's we can use AsyncSubject.
Top comments (0)