Files
elm-0.19-workshop/part7/Main.elm
2016-06-25 08:30:39 -07:00

32 lines
697 B
Elm

port module Main exposing (..)
import ElmHub exposing (..)
import Html.App
import Json.Decode
main : Program Never
main =
Html.App.program
{ view = view
, update = update githubSearch
, init = ( initialModel, githubSearch (getQueryUrl initialModel.query) )
, subscriptions = \_ -> githubResponse decodeResponse
}
decodeResponse : Json.Decode.Value -> Msg
decodeResponse json =
case Json.Decode.decodeValue responseDecoder json of
Err err ->
SetErrorMessage (Just err)
Ok results ->
SetResults results
port githubSearch : String -> Cmd msg
port githubResponse : (Json.Decode.Value -> msg) -> Sub msg