I think this is probably a question not a feature request or bug.
How do we send data to child actors within a machine?
Looking at the example from the docs, we can spawn an actor and send events to it but I'm not sure how to add data to the event.
entry: assign({
someRef: () => spawn(someMachine)
}),
on: {
SOME_EVENT: {
// I want to send some custom data (from either the SOME_EVENT data or the local context) to the PING event
actions: send('PING', {
to: context => context.someRef,
})
}
}
With the sendParent API I can do the following:
actions: sendParent(context => ({
type: 'UPDATE_FROM_CHILD',
data: context
}))
Does a similar API exist for parent -> child 馃 communication?
Yes:
actions: send({
type: 'SOME_EVENT',
somePayload: 'whatever you want'
}, { to: context => context.someRef })
I'll add this to the docs too.
Most helpful comment
Yes: