ccapndave/elm-statecharts/4.0.1

Statechart

A pure Elm implementation of statecharts designed to hook directy 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.

Statechart msg model
-> 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 : 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.

Config msg model
-> ( model, Cmd msg )
-> Result String ( model, Cmd msg )

Start the statechart in its starting state. This can fail in the case of a badly configured statechart.

Config msg model
-> msg
-> ( model, Cmd msg )
-> Result String ( model, Cmd msg )

Step through the statechart in response to an incoming message. This can fail in the case of non-existant state names.