Introduction to state management with @ngrx/store
State management in large Angular applications was a weak point over the last few years. In AngularJS 1, the state management is often done as a mix of services, events, and $rootScope
. In Angular 2+, the application state and data flow are cleaner but there is still no unified state management in Angular core. Developers often use Redux--a predictable state container for JavaScript applications (http://redux.js.org). The Redux architecture is best known for its use with the React library (https://facebook.github.io/react), but it can be utilized with Angular too. One of the popular Redux-like state containers designed for Angular is ngrx/store (https://github.com/ngrx/store).
Redux principles
Redux follows three basic principles:
- The whole state of the application is stored in a single immutable state tree called store. No state management is allowed outside the store. A central immutable store has a lot of benefits. You can improve the performance...