Created
April 20, 2016 11:47
-
-
Save Cspeisman/ab726cd53bff02aa04ae59f9cff28a06 to your computer and use it in GitHub Desktop.
This file contains 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 (..) where | |
import Html exposing (Html) | |
import Html.Events as Events | |
type alias Model = | |
{ count : Int } | |
type Action | |
= NoOp | |
| Increase | |
initialModel : Model | |
initialModel = | |
{ count = 0 | |
} | |
view : Signal.Address Action -> Model -> Html | |
view address model = | |
Html.div | |
[] | |
[ Html.div [] [ Html.text (toString model.count) ] | |
, Html.button | |
[ Events.onClick address Increase ] | |
[ Html.text "Click" ] | |
] | |
update : Action -> Model -> Model | |
update action model = | |
{ model | count = model.count + 1 } | |
mb : Signal.Mailbox Action | |
mb = | |
Signal.mailbox NoOp | |
modelSignal : Signal.Signal Model | |
modelSignal = | |
Signal.foldp update initialModel mb.signal | |
main : Signal.Signal Html | |
main = | |
Signal.map (view mb.address) modelSignal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment