Skip to content

Impure assigner actions #1321

Answered by Andarist
universse asked this question in General
Jul 20, 2020 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hi. Is it an anti pattern if the assigner function is impure?

Yes. assigns should be pure. You could use pure though:

{
  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

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@universse
Comment options

Answer selected by universse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants