Created
August 19, 2015 16:49
-
-
Save alexspurling/99192104ae9f784b98ba to your computer and use it in GitHub Desktop.
This file contains hidden or 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 (..) | |
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