Problem
In large state machines, multiple transitions often lead to the same state (e.g., A → B, C → B, D → B).
Currently, only transitions can define actions. However, some actions are related to entering or exiting a state.
With the current implementation, any entry- or exit-related logic must be duplicated across every transition that leads into or out of that state. This results in code duplication and a greater chance of inconsistency.
Solution
Extend the state machine so that states can define on_entry and on_exit actions.
These actions are executed automatically whenever the state is entered or exited, regardless of which transition triggered the change. This eliminates duplication and provides a clearer, more maintainable design.
Problem
In large state machines, multiple transitions often lead to the same state (e.g., A → B, C → B, D → B).
Currently, only transitions can define actions. However, some actions are related to entering or exiting a state.
With the current implementation, any entry- or exit-related logic must be duplicated across every transition that leads into or out of that state. This results in code duplication and a greater chance of inconsistency.
Solution
Extend the state machine so that states can define on_entry and on_exit actions.
These actions are executed automatically whenever the state is entered or exited, regardless of which transition triggered the change. This eliminates duplication and provides a clearer, more maintainable design.