Angular · Senior · Question 39 of 75

What is NgRx SignalStore?

export const TodosStore = signalStore(
  withState({ todos: [] as Todo[], filter: "all" }),
  withComputed(({ todos }) => ({ count: computed(() => todos().length) })),
  withMethods((store) => ({ setFilter: (filter: string) => patchState(store, { filter }) })),
);

Explanation

SignalStore has no actions or reducers by default: state is a set of signals, updated with patchState. It can be provided in root or per component and extended with custom features.

Further reading

Problem with a question

Angular · Senior · question 39

Test yourself

Take the Angular · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz