Question presented to candidate: "Our team is debating whether to add NgRx to a growing Angular app. Explain what NgRx is, walk me through how data flows through it, and tell me when you would and would not use it."
What a strong answer should cover:
- NgRx is a family of reactive state-management libraries for Angular;
@ngrx/storeimplements the Redux pattern with RxJS and signals. - The building blocks: actions (named events), reducers (pure functions
(state, action) => newState), the store (one immutable state tree), selectors (memoized queries), and effects for side effects such as HTTP. - Unidirectional data flow: component dispatches, reducer computes, selector reads; no component mutates shared state directly.
- Benefits: predictability, Redux DevTools time-travel debugging, testable pure functions, clear separation of concerns. Costs: boilerplate and indirection, which
createActionGroup/createFeaturereduce. - Modern details:
provideStore()/provideState()for standalone apps,store.selectSignal(), runtime immutability checks in dev mode, and NgRx SignalStore (@ngrx/signals) as the lighter, signal-based option. - When not to use it: small apps or local UI state, where a service with signals is enough.
Clarifying questions expected:
- "How much state is shared between distant parts of the app, and how many developers touch it?"
- "Do we need features such as undo, time-travel debugging or strict auditing of state changes?"
Code / implementation expected: Optional β a small feature with actions, a reducer, a selector and a component dispatching and reading.