gocardless / statesman

A statesmanlike state machine library.
https://gocardless.com/blog/statesman/
MIT License
1.78k stars 163 forks source link

Added methods to remove states and transitions from state machines. #464

Closed benk-gc closed 2 years ago

benk-gc commented 2 years ago

Historically, when a state machine uses a template and wants to remove a state or transition it will just set a guard that always returns false. This isn't a particularly neat solution since the states and transitions still exist on the state machine, and can make inspecting the internals of the state machine return misleading information.

This change adds explicit methods to allow a state machine to delete states or transitions. When a state is deleted, all related transitions and callbacks will also be cleaned up as appropriate.