Last active
June 29, 2017 15:49
-
-
Save aceakash/62baa2c66e6415c7980f4ecb02154a9b to your computer and use it in GitHub Desktop.
Elm boilerplate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main exposing (..) | |
import Html exposing (Html, button, div, h1, text) | |
import Html.Events exposing (onClick) | |
main = | |
Html.program | |
{ init = ( initialModel, Cmd.none ) | |
, view = view | |
, update = update | |
, subscriptions = subscriptions | |
} | |
-- MODEL | |
type alias Model = | |
Int | |
initialModel : Model | |
initialModel = | |
0 | |
-- UPDATE | |
type Msg | |
= Increment | |
update : Msg -> Model -> ( Model, Cmd Msg ) | |
update msg model = | |
case msg of | |
Increment -> | |
( model + 1, Cmd.none ) | |
-- SUBSCRIPTIONS | |
subscriptions : Model -> Sub Msg | |
subscriptions model = | |
Sub.none | |
-- VIEW | |
view : Model -> Html Msg | |
view model = | |
div [] | |
[ h1 [] [ text (toString model) ] | |
, button [ onClick Increment ] [ text "Increment" ] | |
] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment