PaackEng / paack-ui / UI.Effects

UI.Effect is a combination of every command required for paack-ui to work correctly. The data describing each side-effect is publicly available, performing the side-effects is left to the user.

Can be used along with elm-program-test to test your application flow.

This module parallels elm/core's Platform.Cmd module, but with some additional helpers for creating Effect values.

Note: If you don't know about commands yet, do not worry if this seems confusing at first, commands will make more sense if you go through the Elm Architecture Tutorial first to see how they fit in real applications.

Create


type alias Effects msg =
List (SideEffect msg)

A list of side-effects to be performed later.


type SideEffect msg
    = MsgToCmd msg
    | DomFocus (Result Browser.Dom.Error () -> msg) String
    | Analytics UI.Analytics.Analytics

The SideEffect msg type is used for describing commands for later inspection.

none : Effects msg

Tells the perform function that there are no side-effects. Parallels Cmd.none.

batch : List (Effects msg) -> Effects msg

Batch effects together. Parallels Cmd.batch.

msgToCmd : msg -> Effects msg

The effect of returning a msg.

analytics : UI.Analytics.Analytics -> Effects msg

The effect of returning Analytics.

domFocus : (Result Browser.Dom.Error () -> msg) -> String -> Effects msg

The dom focus effect constructor.

Transform

map : (a -> b) -> Effects a -> Effects b

Transform the messages produced by a effect. Parallels Cmd.map.

perform : Effects msg -> Platform.Cmd.Cmd msg

Perform a minimal interpretation of side-effects into commands. Use this if you don't care to change how to interpret them.