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 pageshowhide
explore
- Store Setup & Actions6 questions
- Reducers & Feature Slices5 questions
- Selector Memoization5 questions
- Action-Driven Effects6 questions
- Signal Store Anatomy6 questions
- Signal Store Extensions6 questions
- Entity Adapters & Local Stores5 questions
- Mock Stores & Effect Tests6 questions
questions
page 2 of 2With 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?
basics
~20 seventGroup 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.
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?
basics
~20 sA 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.
With an NgRx SignalStore, why does patchState(this.store, { trackFilter: 'web' }) in a component fail to compile, and how should you fix it?
basics
~20 sSignalStore 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.
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?
basics
~20 sA 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.
In NgRx, what do provideStoreDevtools' maxAge and logOnly defaults mean for a production build, and how would you configure the DevTools there?
basics
~20 sprovideStoreDevtools 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.
In NgRx, how do you unit-test a payment effect with provideMockActions, and prove that a declined charge does not kill the effect?
basics
~20 sProvide 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.
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?
basics
~10 ssetResult 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.
For a large Angular app on NgRx 22, how do you decide between the global Store and SignalStores, and where does signalState fit?
basics
~20 sNeither 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.
In NgRx, what does an entity adapter's getSelectors() return, and why pass it a selector for the board's feature state?
basics
~10 sgetSelectors() 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.
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?
basics
~20 sconcatLatestFrom 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.
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?
basics
~20 sThe 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.
In an NgRx SignalStore, what do withProps and withLinkedState add that withComputed and withState cannot, and when would you use each?
basics
~20 swithProps 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.
In NgRx 22, what does store.dispatch(() => genreChanged({ genre: this.genre() })) do, and how is that reactive dispatch cleaned up?
basics
~20 sPassing 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.
With an NgRx SignalStore whose state is protected, how does a unit test set the store's state directly, and when should it?
basics
~10 sWrap 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.
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?
basics
~20 sPlain 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.
showing 31–45 of 45