Reusable views
Problem
Solution
Main.elm
type alias ButtonModel =
{ text : String
}
type alias Model =
{ button: ButtonModel
}
type ButtonMsg =
ButtonPressed
type Msg =
ButtonSpecific ButtonMsg
| Reset
update : Msg -> Model -> (Model,Cmd Msg)
update msg ({button} as model) =
case msg of
ButtonSpecific ButtonPressed ->
( { model
| button =
{ button
| text = "Thanks!"
}
}
, Cmd.none
)
_ ->
(model, Cmd.none)