Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@foxdonut
Created February 21, 2016 16:31
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 foxdonut/439aa8769a0c34bbe554 to your computer and use it in GitHub Desktop.
Save foxdonut/439aa8769a0c34bbe554 to your computer and use it in GitHub Desktop.
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