Handling global application state with NgRx
When working on enterprise software or an application with extensive or complex state management, you should use a battle-tested state management solution that provides true immutability, unidirectional data flow, and good tools to perform side effects and modify the state securely. The best way forward is to use a battle-tested library that focuses on state management.
The most commonly used library for state management within the Angular community is NgRx; it has a huge community and all the tools you might need to handle even the most complex state. NgRx implements the Redux pattern and consists of four main building blocks: actions, reducers, selectors, and effects.
In this section, we will change our custom-made state management solution so that it uses NgRx. We will keep the store file we made in the previous section for reference purposes and build the NgRx state management in new files.
In a production environment, you should...