Skip to content

Instantly share code, notes, and snippets.

@amitaibu
Created August 31, 2015 21:01
Show Gist options
  • Save amitaibu/4ec789ed57d52cf1d0ac to your computer and use it in GitHub Desktop.
Save amitaibu/4ec789ed57d52cf1d0ac to your computer and use it in GitHub Desktop.
module EventLog where
import Html exposing (..)
import Html.Events exposing (..)
import Html.Attributes exposing (..)
import Signal exposing (..)
import StartApp.Simple exposing (..)
type alias Model =
{ events: List String }
initialModel : Model
initialModel =
{ events = [] }
type Action = Mark String
| Reset
update : Action -> Model -> Model
update action log =
case action of
Mark date ->
{ log | events <- log.events ++ [date] }
Reset ->
{ log | events <- [] }
view : Address Action -> Model -> Html
view address model =
div []
[ button [ onClick address (Mark "?") ] [ text "Mark" ],
button [ onClick address Reset ] [ text "Reset" ],
h2 [] [ text (model.events |> List.length |> toString), text " Events" ],
div [] (List.map (\t -> text t) model.events)
]
main : Signal Html
main =
StartApp.Simple.start
{ model = initialModel,
view = view,
update = update }
@amitaibu
Copy link
Author

@kouphax thanks for your nice post!

It seems that StartApp.Simple is now needed instead of StartApp, so here's the updated code ^^ :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment