skip to content

NgRx

NgRx brings the Redux pattern to Angular — actions, reducers, memoized selectors, RxJS effects — plus the signal-based SignalStore. Interviewers expect it once a question leaves component state.

on this pageshow

explore

questions

page 2 of 2

With the NgRx SignalStore Events plugin, how do eventGroup, withReducer and withEventHandlers cooperate in a notifications flow, and in what order do they see an event?

level: seniorimportance: should knowfreq 21%

basics

~20 s

eventGroup defines events like [Notifications Page] opened; withReducer maps events to state changes; withEventHandlers reacts with side effects and returns new events, which are dispatched. Reducers see each event first, so handlers observe the updated state.

open as a page

In an NgRx SignalStore, when a reusable paging feature needs the host store's loader, when do you declare a typed input and when use withFeature?

level: seniorimportance: should knowfreq 18%

basics

~20 s

A typed input, signalStoreFeature({ methods: type<{ loadPage(i: number): void }>() }, ...), makes the host declare loadPage or fail to compile. withFeature((store) => withPaging((i) => store.fetchUsers(i))) passes the dependency explicitly and keeps the feature independent of host names.

open as a page

With an NgRx SignalStore, why does patchState(this.store, { trackFilter: 'web' }) in a component fail to compile, and how should you fix it?

level: seniorimportance: should knowfreq 38%

basics

~20 s

SignalStore state is protected by default: the store's public type exposes a read-only state source, and patchState needs a writable one. Add a method such as setTrack() in withMethods; protectedState: false also works but drops the guarantee.

open as a page

An NgRx bookstore app dispatches one shared loadBooks action from the catalogue page, the genre filter and a refresh button; why is that poor action hygiene, and how would you restructure it?

level: seniorimportance: should knowfreq 46%

basics

~20 s

A shared loadBooks command hides which source fired it, so the DevTools log shows identical entries and handlers cannot treat sources differently. Dispatch one [Source] Event action per source instead, and let the loading reaction listen for all of them.

open as a page

In NgRx, what do provideStoreDevtools' maxAge and logOnly defaults mean for a production build, and how would you configure the DevTools there?

level: seniorimportance: should knowfreq 33%

basics

~20 s

provideStoreDevtools defaults to maxAge: false, an unbounded action and state history, and logOnly: false, full time travel and dispatch from the extension. In production, cap maxAge and set logOnly from isDevMode(), or leave the DevTools out of the bundle.

open as a page

In NgRx, how do you unit-test a payment effect with provideMockActions, and prove that a declined charge does not kill the effect?

level: seniorimportance: should knowfreq 42%

basics

~20 s

Provide provideMockActions(() => actions$) and a fake payment API, subscribe to the effect and assert the actions it emits; feed a failing charge then a good one and expect a failure action, then a success action.

open as a page

An NgRx MockStore test calls setResult on an overridden cart-total selector, but the view keeps the old total; what is missing, and why reset selectors afterwards?

level: seniorimportance: should knowfreq 30%

basics

~10 s

setResult changes what the selector returns but emits nothing; call store.refreshState() so subscribers re-evaluate. Overrides live on the shared selector objects, so call store.resetSelectors() in afterEach or they leak into later tests.

open as a page

For a large Angular app on NgRx 22, how do you decide between the global Store and SignalStores, and where does signalState fit?

level: principalimportance: should knowfreq 48%

basics

~20 s

Neither replaces the other in NgRx 22. Use the global Store where many features react to shared events and you want an action log and Store DevTools; SignalStores for feature- or view-scoped state; signalState for small private state in one class.

open as a page

In NgRx, what does an entity adapter's getSelectors() return, and why pass it a selector for the board's feature state?

level: middleimportance: nice to knowfreq 26%

basics

~10 s

getSelectors() returns selectIds, selectEntities, selectAll and selectTotal. With no argument they read an EntityState directly; given a selector for the feature slice, they become memoized selectors that start from the root state.

open as a page

In NgRx 22, why use concatLatestFrom from @ngrx/operators instead of withLatestFrom when a price-alert effect needs the traveller's currency from the store?

level: seniorimportance: nice to knowfreq 30%

basics

~20 s

concatLatestFrom calls its factory only when a matching action arrives, passing that action, so the selector is not subscribed at startup and can depend on the action's data. It has lived in @ngrx/operators since NgRx 18.

open as a page

In NgRx 22, what does createFeature's extraSelectors factory receive, and when should a derived orders selector live there rather than in a separate selectors file?

level: seniorimportance: nice to knowfreq 22%

basics

~20 s

The extraSelectors factory receives the selectors createFeature generated (the feature selector and one per property) and returns more, which are merged into the feature object. It suits selectors derived from that one slice; joins across features belong in a separate file.

open as a page

In an NgRx SignalStore, what do withProps and withLinkedState add that withComputed and withState cannot, and when would you use each?

level: seniorimportance: nice to knowfreq 26%

basics

~20 s

withProps adds arbitrary members, such as observables, injected services or private helpers, that are not state. withLinkedState adds state slices derived from other signals that stay writable with patchState and recompute when their sources change.

open as a page

In NgRx 22, what does store.dispatch(() => genreChanged({ genre: this.genre() })) do, and how is that reactive dispatch cleaned up?

level: seniorimportance: nice to knowfreq 24%

basics

~20 s

Passing a function to Store.dispatch creates an Angular effect that dispatches the returned action initially and again whenever a signal read inside it changes. It returns an EffectRef, and ends with its injector: the caller's, a passed one, or the root.

open as a page

With an NgRx SignalStore whose state is protected, how does a unit test set the store's state directly, and when should it?

level: seniorimportance: nice to knowfreq 22%

basics

~10 s

Wrap the store in unprotected() from @ngrx/signals/testing and call patchState on it; use that only to arrange state no public method can reach, and prefer driving the store through its own methods.

open as a page

For a team standardising on NgRx SignalStore, when should stores react through the Events plugin rather than plain store methods, and what conventions would you set?

level: principalimportance: nice to knowfreq 14%

basics

~20 s

Plain store methods stay the default; the Events plugin pays off when several stores react to one occurrence or must not know each other. Conventions: one update style per slice, pure reducers, I/O in handlers, scoped dispatchers.

open as a page

showing 31–45 of 45