Open joepie91 opened 6 years ago
As an aside: this issue originally caused a strange bug in my application where I'd get inconsistent states; a child FSM would transition from state A to state B, but then when handle
ing a command it would suddenly be in state A again, despite no transition event from B -> A having ever been emitted on the parent FSM (and this wasn't a possible transition in the first place). Presumably there were difference instances of the child FSM, where one of them was in state A and the other was in state B.
This may or may not be indicative of a bug elsewhere. I'm unsure how reproducible the issue is, and I haven't had the time to try it. This PR plus my other one make the bug go away, however.
Thanks @joepie91. I'm working on catching up on PRs this week (finally have some time off!).
This fixes the second issue that I mentioned in #154; it ensures that new child FSMs are only instantiated when transitioning to a new child-containing state, not when eg.
handle
ing a command that's received by a child.As before, I've created a bugcase to demonstrate it, including an example of the erroneous results: https://git.cryto.net/joepie91/machina-factory-bugcase/src/child-switch
Of note:
lib/
in this PR due to merge conflict risks.