Skip to content

Instantly share code, notes, and snippets.

@knewter
Created August 9, 2016 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knewter/fb78ea234b5a7dd6f2fd340c4cc483f5 to your computer and use it in GitHub Desktop.
Save knewter/fb78ea234b5a7dd6f2fd340c4cc483f5 to your computer and use it in GitHub Desktop.
Introduction to elm-mdl - 6
type alias Model =
{ count : Int
, mdl :
Material.Model
-- Boilerplate: model store for any and all Mdl components you use.
, selectedTab : Int
}
model : Model
model =
{ count = 0
, mdl =
Material.model
-- Boilerplate: Always use this initial Mdl model store.
, selectedTab = 0
}
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
-- ...
SelectTab num ->
{ model | selectedTab = num } ! []
viewBody : Model -> Html Msg
viewBody model =
case model.selectedTab of
0 ->
viewCounter model
1 ->
text "something else"
_ ->
text "404"
-- Renamed again!
viewCounter : Model -> Html Msg
viewCounter model =
-- ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment