-
I want create FSM1, FSM2, FSM3. // root FSM
entry: {
spawn(FSM1, "FSM1"),
spawn(FSM2, "FSM2"),
spawn(FSM3, "FSM3"),
}
// FSM3
{
on: {
update: {
actions: (ctxOfFSM3, event) => send(event, { to: "FSM1" }) // Unable to send event to child 'FSM1' from service 'FSM3'
}
}
} Or in one machine: // root FSM same as computed state for FSM3 from FSM{1,2}
type: "parallel",
states: {
FSM1: FSM1,
FSM2: FSM2,
FSM3: FSM3,
}
// FSM{1,2}
{
id: "FSM1",
steates: { idle: { on: { update: {
actions: actions.respond({
type: idle, // to FSM3
value: 1, // like FSM1 say what FSM1 in state "1"
}),
} } } }
}
// FSM3
{
on: {
idle: {}, // from FSM1 and swich FSM3 to FSM* state
update: [{ // like ask FSM* about states
actions: (ctxOfFSM3, event) => send(event, { to: "#FSM1.idle" }) // but 'to' not FSM3 parent or children
}]
}
} But i can create common action in root FSM, and resend all events down. But how can i send events from FSM3 to FSM1 and FSM2 and toggle FSM3 if FSM1 and FSM2 respond with same value(without context)? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
If I understand correctly, you're asking about sibling communication. The way to do this would be to go hierarchically - send an event to the parent which should (with custom logic) route it to the correct child. Is there any problem with going through the parent first? |
Beta Was this translation helpful? Give feedback.
-
Parallel states must be independent but may be partially polymorphic. The problem in which two parallel states interact can be solved either by introducing a supervisor of a blocking event or by constraints on variables. Variables are chosen to break such transitions. Don't use redirect for this. |
Beta Was this translation helpful? Give feedback.
Parallel states must be independent but may be partially polymorphic. The problem in which two parallel states interact can be solved either by introducing a supervisor of a blocking event or by constraints on variables. Variables are chosen to break such transitions. Don't use redirect for this.