skip to content

Signal Store Extensions

Custom features package reusable slices of a SignalStore; withEntities, rxMethod and the Events plugin extend it. Interviewers ask how to share logic across stores without base classes.

on this pageshow

explore

questions

6

With an NgRx SignalStore, how do you share loading and paging logic between a products store and a users store without a base class?

level: middleimportance: must knowfreq 34%

basics

~10 s

Write a withPaging() function that returns signalStoreFeature(withState(...), withComputed(...)) for the page index, loading flag and error, then add it to both signalStore() calls. Each store gets its own independent copy of that state.

open as a page

In an NgRx SignalStore that uses withEntities for products keyed by sku, how do addEntity, setEntity and upsertEntity differ, and where does selectId go?

level: middleimportance: should knowfreq 27%

basics

~20 s

For an existing id, addEntity keeps the stored product, setEntity replaces it and upsertEntity merges the given properties. withEntities takes no id selector; pass selectId to each add, set, upsert and update call, or bundle it with entityConfig.

open as a page

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

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