NgRx (state management) - flowup/knowledge GitHub Wiki
NgRx is a state management library for Angular. Inspired by Redux (and leveraging RxJS), it's designed to help keep app state changes maintainable by applying the following core principles.
- Data is stored in a single global immutable state object (store) acting as a single source of truth.
- Queries (selectors) are separated from commands (actions) (CQS principle) in order to maintain a uni-directional dataflow.
- New state is derived from old state in response to actions using pure functions (reducers).
- A separate mechanism (effects) is defined for side-effects (e.g. network requests).
🛠️ Packages
- @ngrx/store - core library (store, reducers, actions, selectors)
- @ngrx/store-devtools - integrates with Redux DevTools browser extension
- @ngrx/effects - includes side-effects
- other options:
- @ngrx/router-store - synchronizes store with Angular router
- @ngrx/entity - encapsulates normalization of data collections
💬 Talks
- Storing router state by Vojtech Mašek (Google slides, PDF, repo)
- NgRx effects and web sockets by Pavel Tobiáš (PDF slides, source code)