matthewp / robot

🤖 A functional, immutable Finite State Machine library

Home Page:https://thisrobot.life

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

First event with nested machine as a first state is missed

NastyaLo opened this issue · comments

In nested machines an event is needed to fall throught to start interact with a child machine.

When we have a child machine as a first state of a parent machine - initially we are in the parent machine. If we want to send an event to the child machine - we need to send any event to the parent machine. Only after that child machine will receive events.

There is a small example that reproduses the issue: https://codesandbox.io/s/robot3-react-nested-example-8dtcd

Is that expected behavior?

Yeah, I can see how this is confusing.

  • Maybe this is just the expected behavior of Robot (in which case the docs should be updated to note “Robot will never immediately transition to a child machine; write your code accordingly”); OR,
  • Maybe there is a way to get this to behave as you want using immediate(); OR
  • …Maybe it’s just a bug!

@matthewp Could you advise on how to proceed?