Personally, if you're trying to do something async you might be better off writing your own state machine system from scratch.
However, I guess if you think about it, there's actually an intermediate state where you were in one state, you got the signal, and now you're waiting until the code completes async and you can move to the next state.
If you had state 1 and state 2, this could be state 1_busy:
In state 1
Signal received : stuff happens, move to state 1_busy
Stuff completes async, move to state2
So in that case I think you can do it with the current system. The handler for state 1 returns 1_busy, and then it sends a signal to the FSM when it properly completes, which causes 1_busy to change to 2?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Personally, if you're trying to do something async you might be better off writing your own state machine system from scratch.
However, I guess if you think about it, there's actually an intermediate state where you were in one state, you got the signal, and now you're waiting until the code completes async and you can move to the next state.
If you had state
1
and state2
, this could be state1_busy
:So in that case I think you can do it with the current system. The handler for state 1 returns
1_busy
, and then it sends a signal to the FSM when it properly completes, which causes1_busy
to change to2
?