Async invoke with multiple destination states onDone #5163
Unanswered
kayden1940
asked this question in
Q&A
Replies: 1 comment
-
|
try returning a value from your async actor then using a guarded transition onDone: something like: const machine = setup({
actors: {
asyncActor: fromPromise(async () => {
return condition ? 'foo' : 'bar'
}),
},
}).createMachine({
states: {
State: {
invoke: {
src: 'asyncActor',
onDone: [
{
target: 'Foo',
guard: ({ event }) => event.output === 'foo',
},
{
target: 'Bar',
guard: ({ event }) => event.output === 'bar',
},
{
target: 'Default'
}
],
},
},
},
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How should this be done? Thanks you.
Beta Was this translation helpful? Give feedback.
All reactions