I'm trying to refactor my state by creating a reusable function that handles a patch. How can I access setState and patchState without this strange context argument?
updateThings(ctx: StateContext<TaskStateModel>, { payload }: any): any {
ctx.setState(
patch({
I am not sure if this addresses your concern. But you could destructure the code a bit so you don't have to use
ctx.patchState(), etc, etc.Note - I should also mention
patchStatewould only patch the top level attributes. If you have a deeply nested state object you will have to manage the merging yourself. Technically you want to break them out to their own state.for eg: