Highlighting other ways for sharing data
The previous pattern for sharing data has many benefits:
- Improves the sharing of data between unrelated components
- Manages mutability risk
- Makes communication between components easier
We can use Angular services and RxJS's BehaviorSubject
to manage our application's state. This works perfectly in many situations, but for big applications where there are a lot of user interactions and multiple data sources, managing states in services can become complicated.
In this case, we can use a state management library to manage the state of our application, which is the main goal of state management libraries.
There are many great state management libraries out there to manage states in Angular. The most popular is NgRx
. All the state management libraries have one thing in common – they are built on top of RxJS Observables and the state is stored in BehaviorSubject
.
Note
For further details about...