Effects, Entity & Choosing the Right Level of NgRx
Effects — Where Side Effects Live
loadItems$ = createEffect(() =>
this.actions$.pipe(
ofType(loadItems),
switchMap(() =>
this.api.getItems().pipe(
map((items) => loadItemsSuccess({ items })),
catchError((error) => of(loadItemsFailure({ error })))
)
)
)
)Since reducers must stay pure and synchronous, Effects (built on RxJS operators) are where async work like HTTP calls happens. The idiomatic pattern: a triggering action → the Effect performs the side effect → dispatches a success or failure action, which a reducer then handles normally.
@ngrx/entity — Normalized Collections
const adapter = createEntityAdapter<Item>()
// state shape: { ids: string[], entities: { [id]: Item } }
const reducer = createReducer(
adapter.getInitialState(),
on(loadItemsSuccess, (state, { items }) => adapter.setAll(items, state))
)Storing collections normalized (an ids array plus an id-keyed entities dictionary) gives O(1) lookups/updates and avoids re-creating the whole array reference on unrelated changes — @ngrx/entity provides consistent adapter helpers (addOne, updateOne, removeMany) instead of hand-written array manipulation.
ComponentStore & Signals — Lighter Alternatives
The classic action/reducer/effects/selector stack is real boilerplate for simple state. ComponentStore offers Store-like ergonomics scoped to a single component or feature, without global actions and reducers. The newer @ngrx/signals package builds state management around Angular Signals directly, trimming ceremony further for cases that don't need the full architecture.
When the Full Store Is Worth It
Reach for the full NgRx Store when state is shared across many unrelated components, involves complex async flows, and benefits from devtools-level traceability (time-travel debugging via @ngrx/store-devtools, built on Redux DevTools). Smaller or localized state is usually better served by component state, a service with a BehaviorSubject, ComponentStore, or Signals.
Keep your own version of these notes — editable, searchable, and organised by your stack.
Start free