Closed translunar closed 1 year ago
I found a workaround, which is to refer to the function by reference instead of by string, e.g. "conditions": self.test
. However, this condition seems to get called on every internal state transition instead of just the trigger it's defined on.
Hello @translunar,
as of now this is intended behaviour. The documentation mentions
(Nested)State instances are just referenced which means changes in one machine's collection of states and events will influence the other machine instance. Models and their state will not be shared though.
Strings as callbacks will always be treated as methods assigned to the currently processed model. You could either use inheritance or reference methods directly (as you just did).
It might be helpful to clarify this in the documentation. I had to dig through the issues to find it.
Describe the bug When I define a machine with
and the
child
model defines a transition with"conditions": "test"
, it attempts to calltest()
on the parent model rather than the nested model.Minimal working example
Expected behavior I expect
test()
to get called on the child model and not the parent model.Additional context Add any other context about the problem here.