A pure Elm implementation of statecharts designed to hook directy into The Elm Architecture update function.
Tree (StateConfig msg model)
{ currentStateName : String
, targetStateName : String
, history : Dict String String
}
decoder : Json.Decode.Decoder StateModel
Decode a stored StateModel.
encode : StateModel -> Json.Encode.Value
Encode the StateModel into a value ready to be stored in the main model.
mkStatechart : Statechart msg model -> List (Statechart msg model) -> Statechart msg model
Make the top level statechart
mkCompoundState : BranchStateConfig msg model -> List (Statechart msg model) -> Statechart msg model
Make a compound state from a StateConfig
mkState : LeafStateConfig msg model -> Statechart msg model
Make a state from a StateConfig
noAction : Maybe model -> msg -> ( msg, List model )
The identity action that does nothing
empty : StateModel
An empty StateModel; this is the initial value in the model.
start : Config msg model -> ( model, Platform.Cmd.Cmd msg ) -> Result String ( model, Platform.Cmd.Cmd msg )
Start the statechart in its starting state. This can fail in the case of a badly configured statechart.
step : Config msg model -> msg -> ( model, Platform.Cmd.Cmd msg ) -> Result String ( model, Platform.Cmd.Cmd msg )
Step through the statechart in response to an incoming message. This can fail in the case of non-existant state names.