Is it possible to "assign" multiple times within a single "action"? #1775
Answered
by
davidkpiano
Sheldonfrith
asked this question in
Q&A
-
I'm trying to use a single "action" to spawn multiple actors. However as each "spawn" has to be within an "assign" call I'm a little stuck. How can I queue multiple "assign" calls within a single "actor"? I cannot find any examples of this in the docs. |
Beta Was this translation helpful? Give feedback.
Answered by
davidkpiano
Dec 24, 2020
Replies: 1 comment 1 reply
-
You can use the actions: assign({
someActors: () => {
return [/* array of things */].map(thing => spawn(createSomeMachine(thing)))
}
}); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Sheldonfrith
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use the
pure()
action creator to do multiple assigns, but it sounds like you might not need to: