Firstly, here’s the code. I need to fix.
Basically, there are two machines:
currentStateMachine
:- currently, I want to change the state manually (running
send
commands) once a second based on the real state; - later, it might be better to run a callback function based on which the state would change, however, currently I have no idea if it could work like that;
- I use
context
to store the current timestamp and the state; - PROBLEM: how to invoke
intervalsMachine
with thecontext
ofcurrentStateMachine
? - QUESTION: will
currentStateMachine
wait forinvoke
completion before accepting another state event? Or will it wait until the state is processed and only after that a new event is processed?
- currently, I want to change the state manually (running
intervalsMachine
:- it creates an interval from the current states whenever a new state is received;
- it uses
context
to storestartTime
of the interval, itslength
and the state during this interval; - the interval calculation is simplified for demostration, in will be much more complex.
TL;DR
How to invoke
intervalsMachine
(invoked machine) with thecontext
ofcurrentStateMachine
(machine that invokesintervalsMachine
)?Will
currentStateMachine
wait forinvoke
completion before accepting another state event? Or will it wait until the state is processed and only after that a new event is processed?