Upgrade everything to 0.18
This commit is contained in:
@@ -5,13 +5,11 @@ import Html exposing (..)
|
||||
import Html.Attributes exposing (class, target, href, property, defaultValue)
|
||||
import Html.Events exposing (..)
|
||||
import Http
|
||||
import Html.App as Html
|
||||
import Task exposing (Task)
|
||||
import Json.Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (..)
|
||||
|
||||
|
||||
main : Program Never
|
||||
main : Program Never Model Msg
|
||||
main =
|
||||
Html.program
|
||||
{ view = view
|
||||
@@ -32,17 +30,13 @@ searchFeed query =
|
||||
++ "+language:elm&sort=stars&order=desc"
|
||||
|
||||
-- HINT: responseDecoder may be useful here.
|
||||
task =
|
||||
"TODO replace this String with a Task using http://package.elm-lang.org/packages/evancz/elm-http/latest/Http#get"
|
||||
request =
|
||||
"TODO replace this String with a Request built using http://package.elm-lang.org/packages/elm-lang/http/latest/Http#get"
|
||||
in
|
||||
-- TODO replace this Cmd.none with a call to Task.perform
|
||||
-- http://package.elm-lang.org/packages/elm-lang/core/latest/Task#perform
|
||||
-- TODO replace this Cmd.none with a call to Http.send
|
||||
-- http://package.elm-lang.org/packages/elm-lang/http/latest/Http#send
|
||||
--
|
||||
-- HINT: pass these to Task.perform, but in a different order than this!
|
||||
--
|
||||
-- task
|
||||
-- HandleSearchResponse
|
||||
-- HandleSearchError
|
||||
-- HINT: request and HandleSearchResponse may be useful here.
|
||||
Cmd.none
|
||||
|
||||
|
||||
@@ -120,8 +114,7 @@ type Msg
|
||||
= Search
|
||||
| SetQuery String
|
||||
| DeleteById Int
|
||||
| HandleSearchResponse (List SearchResult)
|
||||
| HandleSearchError Http.Error
|
||||
| HandleSearchResponse (Result Http.Error (List SearchResult))
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
@@ -130,21 +123,23 @@ update msg model =
|
||||
Search ->
|
||||
( model, searchFeed model.query )
|
||||
|
||||
HandleSearchResponse results ->
|
||||
( { model | results = results }, Cmd.none )
|
||||
HandleSearchResponse result ->
|
||||
case result of
|
||||
Ok results ->
|
||||
( { model | results = results }, Cmd.none )
|
||||
|
||||
HandleSearchError error ->
|
||||
-- TODO if decoding failed, store the message in model.errorMessage
|
||||
--
|
||||
-- HINT 1: Remember, model.errorMessage is a Maybe String - so it
|
||||
-- can only be set to either Nothing or (Just "some string here")
|
||||
--
|
||||
-- Hint 2: look for "decode" in the documentation for this union type:
|
||||
-- http://package.elm-lang.org/packages/evancz/elm-http/latest/Http#Error
|
||||
--
|
||||
-- Hint 3: to check if this is working, break responseDecoder
|
||||
-- by changing "stargazers_count" to "description"
|
||||
( model, Cmd.none )
|
||||
Err error ->
|
||||
-- TODO if decoding failed, store the message in model.errorMessage
|
||||
--
|
||||
-- HINT 1: Remember, model.errorMessage is a Maybe String - so it
|
||||
-- can only be set to either Nothing or (Just "some string here")
|
||||
--
|
||||
-- Hint 2: look for "decode" in the documentation for this union type:
|
||||
-- http://package.elm-lang.org/packages/elm-lang/http/latest/Http#Error
|
||||
--
|
||||
-- Hint 3: to check if this is working, break responseDecoder
|
||||
-- by changing "stargazers_count" to "description"
|
||||
( model, Cmd.none )
|
||||
|
||||
SetQuery query ->
|
||||
( { model | query = query }, Cmd.none )
|
||||
|
||||
Reference in New Issue
Block a user