TypeState
TypeState copied to clipboard
Allow for sharing of Transition functions
Bug
As referenced in #20, transition functions can be shared across FSM to be more memory efficient since they don't need a reference to their parent FSM.
Proposed fix
Allow for transition functions to be set either in the constructor of the fsm or as a property.
var fsm = new typestate.FiniteStateMachine<States>(State.StartState, [...transistionFunctions]);
// or
var fsm = new typestate.FinitStateMachine<States>(State.StartState);
fsm.functions = [...transitionFunctions];