diff --git a/src/app/app.state.ts b/src/app/app.state.ts index ec1c3ff..9357c3b 100644 --- a/src/app/app.state.ts +++ b/src/app/app.state.ts @@ -1,4 +1,4 @@ -import { signalStore, withState } from '@ngrx/signals'; +import { patchState, signalStore, withMethods, withState } from '@ngrx/signals'; export type AppState = { currentView: CurrentView; @@ -12,4 +12,14 @@ const initialState: AppState = { currentView: CurrentView.StartingPoint, }; -export const AppStateStore = signalStore({ providedIn: 'root' }, withState(initialState)); +export const AppStateStore = signalStore( + { providedIn: 'root' }, + withState(initialState), + withMethods(store => ({ + updateCurrentView: (currentView: CurrentView) => + patchState(store, () => ({ + ...store, + currentView, + })), + })) +);