ccapndave/elm-statecharts/2.0.1

NOTE: this package is not compatible with Elm 0.19.1

Statechart

A pure Elm implementation of statecharts designed to hook direct;y into The Elm Architecture update function.

type alias Statechart msg model =
Tree (StateConfig msg model)
type alias StateModel =
{ currentStateName : String
, targetStateName : String
, history : Dict String String
}
decoder : Decoder StateModel

Decode a stored StateModel.

encode : StateModel -> Value

Encode the StateModel into a value ready to be stored in the main model.

mkStatechart : String -> List (Statechart msg model) -> Statechart msg model

Make the top level statechart

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 : Action model msg

The identity action that does nothing

empty : StateModel

An empty StateModel; this is the initial value in the model.

start : Config msg model -> ( model, Cmd msg ) -> ( model, Cmd msg )

Start the statechart based on the StateModel.

step : Config msg model -> msg -> ( model, Cmd msg ) -> ( model, Cmd msg )

Step through the statechart in response to an incoming message.