mirror of
https://github.com/correl/elm-paginated.git
synced 2024-11-23 11:09:51 +00:00
Update README
This commit is contained in:
parent
075d9475e2
commit
21bbd017a6
1 changed files with 7 additions and 25 deletions
32
README.md
32
README.md
|
@ -26,11 +26,11 @@ to mean the final page of results has been reached.
|
||||||
import Paginated exposing (Response(..))
|
import Paginated exposing (Response(..))
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
{ results : Maybe (Paginated.Response String) }
|
{ results : Maybe (List String) }
|
||||||
|
|
||||||
type Msg
|
type Msg
|
||||||
= Search
|
= Search
|
||||||
| Results (Result Http.Error (Paginated.Response String))
|
| Results (Result Http.Error (List String))
|
||||||
|
|
||||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||||
update msg model =
|
update msg model =
|
||||||
|
@ -38,30 +38,12 @@ to mean the final page of results has been reached.
|
||||||
Search ->
|
Search ->
|
||||||
( model, doSearch )
|
( model, doSearch )
|
||||||
|
|
||||||
Results (Ok response) ->
|
Results results ->
|
||||||
case response of
|
( { model | results = Result.toMaybe results }
|
||||||
Partial request results ->
|
, Cmd.none
|
||||||
( { model
|
)
|
||||||
| results =
|
|
||||||
Maybe.map (\x -> Paginated.update x response)
|
|
||||||
model.results
|
|
||||||
}
|
|
||||||
, Paginated.send Results request
|
|
||||||
)
|
|
||||||
|
|
||||||
Complete results ->
|
|
||||||
( { model
|
|
||||||
| results =
|
|
||||||
Maybe.map (\x -> Paginated.update x response)
|
|
||||||
model.results
|
|
||||||
}
|
|
||||||
, Cmd.none
|
|
||||||
)
|
|
||||||
|
|
||||||
Results (Err _) ->
|
|
||||||
( model, Cmd.none )
|
|
||||||
|
|
||||||
doSearch : Cmd Msg
|
doSearch : Cmd Msg
|
||||||
doSearch =
|
doSearch =
|
||||||
Paginated.send Results <|
|
Paginated.send Results <|
|
||||||
Paginated.get "http://example.com/items" string
|
Paginated.get "http://example.com/search?q=abc" string
|
||||||
|
|
Loading…
Reference in a new issue