uncover-co/elm-submodules/1.0.3

NOTE: the latest version is 1.1.0

SubCmd

When setting up a submodule, you should use SubCmd.cmd when you want the submodule itself to handle the messages. However, if you want the message to be "sent" to the host, just use SubCmd.effect.

type alias Model =
    { value : String }


type Msg
    = FetchFromServer
    | GotFromServer String
    | Submit


type Effect
    = SendValue String


update : Msg -> Model -> ( Model, SubCmd Msg Effect )
update msg model =
    case msg of
        FetchFromServer ->
            ( model
            , SubCmd.cmd (fetchFromServer GotFromServer)
            )


        GotFromServer value ->
            ( { value = value }, SubCmd.none )


        Submit ->
            ( model, SubCmd.effect (SendValue model.value) )

Functions

type alias SubCmd msg effect =
SubCmd msg effect
none : SubCmd msg effect
cmd : Cmd msg -> SubCmd msg effect
effect : effect -> SubCmd msg effect
batch : List (SubCmd msg effect) -> SubCmd msg effect

With batch you can actually send cmd's and effect's at the same time!

Submit ->
    ( model, SubCmd.batch
        [ SubCmd.effect (SendValue model.value)
        , SubCmd.cmd (fetchFromServer GotFromServer)
        ]
    )