Skip to content

Instantly share code, notes, and snippets.

@Cspeisman
Created April 20, 2016 11:47
Show Gist options
  • Save Cspeisman/ab726cd53bff02aa04ae59f9cff28a06 to your computer and use it in GitHub Desktop.
Save Cspeisman/ab726cd53bff02aa04ae59f9cff28a06 to your computer and use it in GitHub Desktop.
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