Angular State Management with NgRx

Overview

Getting Started

1 .Why use NgRx

  • Shared: state that is accessed by many components and services.
  • Hydrated: state that is persisted and rehydrated from external storage.
  • Available: state that needs to be available when re-entering routes.
  • Retrieved: state that must be retrieved with a side-effect.
  • Impacted: state that is impacted by actions from other sources.

2. How it works

Key NgRx Concepts

  • Actions describe unique events that are dispatched from components and services.
  • State changes are handled by pure functions called reducers that take the current state and the latest action to compute a new state.
  • Selectors are pure functions used to select, derive and compose pieces of state.
  • State is accessed with the Store, an observable of state and an observer of actions.

Flow of application state in NgRx

3. Getting started

Then in any component or service we just subscribe to the observable and the can retrieve the state object
Ypu can even see a chart of how your state is at a given moment

--

--

Super knuckle kanuckle bill buckle banana truffle.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store