mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-26 05:13:24 +03:00
Update withMetadata to accept a combine function.
This commit is contained in:
parent
f3170ecb81
commit
55e94c3970
@ -96,7 +96,7 @@ all =
|
||||
, retries = 0
|
||||
, timeoutInMs = Nothing
|
||||
}
|
||||
(BackendTask.Http.withMetadata
|
||||
(BackendTask.Http.withMetadata Tuple.pair
|
||||
(BackendTask.Http.expectJson
|
||||
(Decode.field "stargazers_count" Decode.int)
|
||||
)
|
||||
|
@ -208,27 +208,27 @@ expectJson =
|
||||
|
||||
|
||||
{-| -}
|
||||
withMetadata : Expect value -> Expect ( Metadata, value )
|
||||
withMetadata originalExpect =
|
||||
withMetadata : (Metadata -> value -> combined) -> Expect value -> Expect combined
|
||||
withMetadata combineFn originalExpect =
|
||||
-- known-unoptimized-recursion
|
||||
case originalExpect of
|
||||
ExpectJson jsonDecoder ->
|
||||
ExpectMetadata (\metadata -> ExpectJson (jsonDecoder |> Json.Decode.map (Tuple.pair metadata)))
|
||||
ExpectMetadata (\metadata -> ExpectJson (jsonDecoder |> Json.Decode.map (combineFn metadata)))
|
||||
|
||||
ExpectString stringToValue ->
|
||||
ExpectMetadata
|
||||
(\metadata ->
|
||||
ExpectString (\string -> string |> stringToValue |> Tuple.pair metadata)
|
||||
ExpectString (\string -> string |> stringToValue |> combineFn metadata)
|
||||
)
|
||||
|
||||
ExpectBytes bytesDecoder ->
|
||||
ExpectMetadata (\metadata -> ExpectBytes (bytesDecoder |> Bytes.Decode.map (Tuple.pair metadata)))
|
||||
ExpectMetadata (\metadata -> ExpectBytes (bytesDecoder |> Bytes.Decode.map (combineFn metadata)))
|
||||
|
||||
ExpectWhatever value ->
|
||||
ExpectMetadata (\metadata -> ExpectWhatever ( metadata, value ))
|
||||
ExpectMetadata (\metadata -> ExpectWhatever (combineFn metadata value))
|
||||
|
||||
ExpectMetadata metadataToExpect ->
|
||||
ExpectMetadata (\metadata -> withMetadata (metadataToExpect metadata))
|
||||
ExpectMetadata (\metadata -> withMetadata combineFn (metadataToExpect metadata))
|
||||
|
||||
|
||||
{-| -}
|
||||
|
Loading…
Reference in New Issue
Block a user