Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@alexspurling
Created August 19, 2015 16:49
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 alexspurling/99192104ae9f784b98ba to your computer and use it in GitHub Desktop.
Save alexspurling/99192104ae9f784b98ba to your computer and use it in GitHub Desktop.
import Html exposing (..)
import Html.Events exposing (onClick)
import Http
import Json.Decode as Json exposing((:=))
import StartApp.Simple as StartApp
type alias Model =
{ name : String
, amount : Int
}
init =
{ name = "Service",
amount = 0 }
type Action = Request
update action model =
case action of
Request ->
lookupService
view address model =
div []
[ h1 [] [ text model.name ]
, h2 [] [ text (toString model.amount) ]
, button [onClick address Request] [ text "Update" ]
]
decoder =
Json.object2 Model
("name" := Json.string)
("amount" := Json.int)
lookupService =
Http.get decoder "http://private-b6b2d-salondeluxe.apiary-mock.com/"
app =
StartApp.start
{ init = init
, update = update
, view = view
, inputs = []
}
main =
app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment