-
Hi. Is it an anti pattern if the assigner function is impure? I am trying to implement undo/redo functionality using immer patches and handle those patches using another machine. {
actions: {
"undoableAction": assign(ctx => {
const [nextCtx, patches, inversePatches] = produceWithPatches(...)
someService.send('type', { patches })
// or
ctx.someServiceRef.send('type', { patches })
return nextCtx
})
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
Andarist
Jul 20, 2020
Replies: 1 comment 1 reply
-
Yes. {
actions: {
"undoableAction": pure(ctx => {
const [nextCtx, patches, inversePatches] = produceWithPatches(/* ... */)
return [
assign(nextCtx),
send({ type: 'type', patches }, { to: ctx.someServiceRef })
]
})
}
} BTW you might be interested in this PR: #1318 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
universse
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes.
assign
s should be pure. You could usepure
though:BTW you might be interested in this PR: #1318