import { StateMachine } from "https://deno.land/x/websocket_broadcastchannel@0.8.0/src/state-machine.ts";
A state machine.
Constructors
new
StateMachine(initialState: S,
onBeforeTransition?: OnBeforeTransition<S>,
onDisallowedTransition?: OnDisallowedTransition<S, E>,
allowedTransitions?: TransitionDefinition<S>[],
Construct a new StateMachine.
Type Parameters
optional
E extends ErrorResponse = neverThe type of the error response from the onDisallowedTransition callback.
Properties
private
_state: Sprivate
readonly
onBeforeTransition: OnBeforeTransition<S>private
readonly
onDisallowedTransition: OnDisallowedTransition<S, E>private
readonly
promiseQueue: PromiseQueuereadonly
state: SMethods
private
escapePlantUmlString(str?: string): stringprivate
getAnyTransitionMeta(to: S): TransitionMeta<S> | undefinedprivate
setTransition(transition: TransitionDefinition<S> & Required<Pick<TransitionDefinition<S>, "fn">>): voidcreateTransition(to: S): TransitionDefinition<S>
getAvailableTransitions(from?: S): S[]
mayTransitionTo(to: S, from?: S): boolean
Checks if you may transition to the given state.
toPlantUml(title?: string, includeFinal?): string
Returns this state machine's PlantUML diagram.
transitionTo(to: S): E | void | Promise<void>
Static Methods
gotoFn<S>(instanceGetter: () => StateMachine<S>, to: S): OnTransition<S>
Utility function to create a transition function that only immediately transitions to the given state.