Closed louisjmorgan closed 8 months ago
Hi @louisjmorgan,
as of now, this is expected behaviour. set_state
just simply assigns a state to a model (as in it assigns a value to the model's state attribute which is commonly called 'state') but does not trigger any callbacks. You could use the default auto transitions which more or less have the same effect but process state-related callbacks such as after_state_change
.
# instead of machine.set_state("initial")
machine.to_initial()
Fair enough. I think after_state_change
should be called something else in that case, but I understand.
Describe the bug
The after_state_change callback seems to only be triggered by transitions, and not by manually setting the state. This can't be feature, so I can only assume it's a bug.
Minimal working example
output:
Expected behavior
I expect changing the state to trigger the
after_state_change
callback, because the state has changed.