etaque/elm-response/2.0.0

NOTE: this package is not compatible with Elm 0.19.1

Response

Response utilities for Elm Architecture. Build responses from tasks, pipe them, map over.

Construct

type alias Response model msg =
( model, Cmd msg )

A response is an updated model and some cmd.

res : model -> Cmd msg -> Response model msg

Canonical usage: construct a result from model and cmd.

taskRes : model -> (x -> msg) -> (a -> msg) -> Task x a -> Response model msg

Construct a result from model and task.

withCmd : Cmd a -> m -> Response m a

Construct a result from model and cmd, flipped for piping:

{ model | foo = bar }
  |> withCmd someCmd
withTask : (x -> msg) -> (a -> msg) -> Task x a -> model -> Response model msg

Construct a result from model and task, flipped for piping:

{ model | foo = bar }
  |> withTask someTask
withNone : m -> Response m a

Construct a result from model without cmd, flipped for piping:

{ model | foo = bar }
  |> withNone

Transform

mapModel : (m -> m_) -> Response m a -> Response m_ a

Map over model.

mapCmd : (a -> a_) -> Response m a -> Response m a_

Map over cmd.

mapBoth : (m -> m_) -> (a -> a_) -> Response m a -> Response m_ a_

Map over model and cmd.