Created
February 21, 2016 16:31
-
-
Save foxdonut/439aa8769a0c34bbe554 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
import Html exposing (Html, button, div, text) | |
import Html.Events exposing (onClick) | |
type alias Model = String | |
type Action | |
= NoOp | |
| Show Model | |
initialModel : Model | |
initialModel = | |
"Hello" | |
actions : Signal.Mailbox Action | |
actions = | |
Signal.mailbox (Show "WE WILL NEVER SEE THIS") | |
update : Action -> Model -> Model | |
update action model = | |
case action of | |
NoOp -> | |
"Waiting..." | |
Show m -> | |
m | |
model : Signal Model | |
model = | |
Signal.foldp update initialModel actions.signal | |
view : Signal.Address Action -> Model -> Html | |
view address model = | |
div [] | |
[ text model | |
, button [ onClick address (Show "Clicked!") ] [ text "Press me" ] | |
] | |
main : Signal Html | |
main = | |
Signal.map (view actions.address) model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment