mirror of
https://github.com/nunntom/elm-ui-select.git
synced 2024-11-22 11:54:11 +03:00
Update examples
This commit is contained in:
parent
71d65b8886
commit
144527ed0c
@ -63,7 +63,7 @@ update : Msg -> Model -> ( Model, MyEffect )
|
||||
update msg model =
|
||||
case msg of
|
||||
SelectMsg subMsg ->
|
||||
Select.Effect.updateWithRequest (Select.Effect.request FetchCocktails) SelectMsg subMsg model.select
|
||||
Select.Effect.updateWith [ Select.Effect.request FetchCocktails ] SelectMsg subMsg model.select
|
||||
|> Tuple.mapBoth (\select -> { model | select = select }) SelectEffect
|
||||
|
||||
|
||||
|
@ -8,6 +8,7 @@ import Html exposing (Html)
|
||||
import Resources.ClearButton
|
||||
import Select exposing (Select)
|
||||
|
||||
|
||||
main : Program () Model Msg
|
||||
main =
|
||||
Browser.element
|
||||
|
@ -62,16 +62,16 @@ update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
update msg model =
|
||||
case msg of
|
||||
SelectMsg subMsg ->
|
||||
Select.updateWithRequest (Select.request fetchCocktails) SelectMsg subMsg model.select
|
||||
Select.updateWith [ Select.request fetchCocktails ] SelectMsg subMsg model.select
|
||||
|> Tuple.mapFirst (\select -> { model | select = select })
|
||||
|
||||
|
||||
fetchCocktails : String -> Cmd (Select.Msg Cocktail)
|
||||
fetchCocktails : String -> Cmd Msg
|
||||
fetchCocktails query =
|
||||
Http.get
|
||||
{ url = "https://thecocktaildb.com/api/json/v1/1/search.php?s=" ++ String.replace " " "+" query
|
||||
, expect =
|
||||
Http.expectJson (Select.gotRequestResponse query)
|
||||
Http.expectJson (Select.gotRequestResponse query >> SelectMsg)
|
||||
(Decode.field "drinks"
|
||||
(Decode.oneOf
|
||||
[ Decode.list cocktailDecoder
|
||||
|
Loading…
Reference in New Issue
Block a user