StateMachine.Introspection (state_machine v0.1.7)

Introspection functions allow you to collect and analyze meta information about state machine in runtime. For example, you might want to send the full list of states or events to the front-end, so that appropriate control or scale could be rendered. It is also possible to generate the list of currently allowed events, but be careful, this operation can be expensive if you use guards with side-effects.

Summary

Functions

Returns a list of all events of the supplied state machine definition.

Returns a list of all states of the supplied state machine definition.

Returns a list of available events. This function takes a context with populated model, this is necessary to get a current state.

Functions

all_events(sm)

@spec all_events(StateMachine.t(any())) :: [atom()]

Returns a list of all events of the supplied state machine definition.

all_states(sm)

@spec all_states(StateMachine.t(any())) :: [atom()]

Returns a list of all states of the supplied state machine definition.

allowed_events(ctx)

@spec allowed_events(StateMachine.Context.t(any())) :: [atom()]

Returns a list of available events. This function takes a context with populated model, this is necessary to get a current state.