#Communicate from spawned to parent on completion
1 messages · Page 1 of 1 (latest)
I'm assuming it's sendParent, although I never use it. 😁 https://stately.ai/docs/actions#send-parent-action
Actions are fire-and-forget effects. When a state machine transitions, it may execute actions. Actions occur in response to events, and are typically defined on transitions in the actions [...] property, or for any transition that exits a state in the state's exit: [...] property.
If I was specifically trying to let the parent machine know that the spawned actor has entered a final state? This seems fairly simple if using an invoked ator, but not clear with a spawned actor
you could probably use onDone.actions to sendParent
iirc getSnapshot() has an output property to get the value of the output as well
You can spawn it with spawn(logic, { syncSnapshot: true })
onDone in the child actor/machine? It looks like onDone on the parent only works if the actor is spawned, not invoked
You will get an event from the child actor as { type: 'xstate.done.actor.ACTOR_ID' } (replace ACTOR_ID with the ID you gave the actor)
in the parent onDone you mean? interesting, doesn't seem to be firing.... Would a brief code example be too much to ask for (meant seriously, not sarcastically - code samples can be a lot of work)