-
|
Hi, I was trying to use the new events API for signalStore. I have a model something like: type StepState = { currentStep: number };
const initialState: StepState = { currentStep: 0 };
const stepEvents = eventsGroup({
source: 'steps',
events: {
next: type<void>(),
previous: type<void>(),
gotoStep: type<number>()
}
});
export const StepStore = signalStore(
withInitialState(initialState),
withReducer(
// This is the area I am getting error
on(stepEvent.next, (state) => ({ currentStep: state.currentStep + 1 })
)
)But it says it doesn't recognise the state on the line highlighted in the code sample. Am I missing something when reactiving to an event with no payload? Thank in advance for any help! |
Beta Was this translation helpful? Give feedback.
Answered by
mopinsk
Nov 8, 2025
Replies: 1 comment
-
|
Even if the event is of export const StepStore = signalStore(
withState(initialState),
withReducer(
on(stepEvents.next, (_, state) => ({ currentStep: state.currentStep + 1 })),
)
); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
rainerhahnekamp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Even if the event is of
type<void>, the event still gets passed to the case reducer as the first parameter.You can use a discard (_) if you don't need it. The second parameter is the current state.