Skip to content

Instantly share code, notes, and snippets.

@jwthomp
Created May 16, 2016 01:03
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 jwthomp/46982edfc6b5bd94ec77eee0887f8de8 to your computer and use it in GitHub Desktop.
Save jwthomp/46982edfc6b5bd94ec77eee0887f8de8 to your computer and use it in GitHub Desktop.
Main.elm
import Html exposing (..)
import Html.App exposing (beginnerProgram, program)
import Html.Events exposing (onClick)
import Task
import Debug
type alias Model = Int
type Msg
= Hello
| Bye
| Fail
| NotFail
init : Int -> (Model, Cmd Msg)
init value =
(value, Cmd.none)
view : Model -> Html Msg
view model =
div []
[ text <| toString model
, button [ onClick Hello ] [ text "Hello" ]
]
update : Msg -> Model -> (Model, Cmd Msg)
update message model =
case message of
Hello -> (model, Task.perform Fail Bye)
Fail -> (model, Cmd.none)
NotFail -> (model, Cmd.none)
Bye -> (model, Cmd.none)
main =
program
{ init = init 2
, update = update
, view = view
, subscriptions = \_ -> Sub.none
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment