Update part8 and part9

This commit is contained in:
Richard Feldman
2016-04-03 08:50:35 -07:00
parent dfbff3f448
commit 63e357f146
11 changed files with 176 additions and 123 deletions

View File

@@ -5,6 +5,9 @@ import ElmHub exposing (..)
import Effects exposing (Effects)
import Task exposing (Task)
import Html exposing (Html)
import Signal
import Json.Encode
import Json.Decode
main : Signal Html
@@ -16,12 +19,40 @@ app : StartApp.App Model
app =
StartApp.start
{ view = view
, update = update
, init = ( initialModel, Effects.task (searchFeed initialModel.query) )
, inputs = []
, update = update search.address
, init = ( initialModel, searchFeed search.address initialModel.query )
, inputs = [ responseActions ]
}
port tasks : Signal (Task Effects.Never ())
port tasks =
app.tasks
search : Signal.Mailbox String
search =
Signal.mailbox ""
port githubSearch : Signal String
port githubSearch =
search.signal
responseActions : Signal Action
responseActions =
Signal.map decodeGithubResponse githubResponse
decodeGithubResponse : Json.Encode.Value -> Action
decodeGithubResponse value =
case Json.Decode.decodeValue responseDecoder value of
Ok results ->
SetResults results
Err message ->
SetErrorMessage (Just message)
port githubResponse : Signal Json.Encode.Value