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
28
README.md
28
README.md
|
@ -26,11 +26,11 @@ to mean the final page of results has been reached.
|
|||
import Paginated exposing (Response(..))
|
||||
|
||||
type alias Model =
|
||||
{ results : Maybe (Paginated.Response String) }
|
||||
{ results : Maybe (List String) }
|
||||
|
||||
type Msg
|
||||
= Search
|
||||
| Results (Result Http.Error (Paginated.Response String))
|
||||
| Results (Result Http.Error (List String))
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
update msg model =
|
||||
|
@ -38,30 +38,12 @@ to mean the final page of results has been reached.
|
|||
Search ->
|
||||
( model, doSearch )
|
||||
|
||||
Results (Ok response) ->
|
||||
case response of
|
||||
Partial request results ->
|
||||
( { 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
|
||||
}
|
||||
Results results ->
|
||||
( { model | results = Result.toMaybe results }
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
Results (Err _) ->
|
||||
( model, Cmd.none )
|
||||
|
||||
doSearch : Cmd Msg
|
||||
doSearch =
|
||||
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