We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quick Summary:
When a variable using Task.perform or Task.attempt is created in the update function, Http.cancel cancels http request in next update loop.
Task.perform
Task.attempt
Http.cancel
https://ellie-app.com/6kdQ4HXVJ2ga1
module Main exposing (main) import Browser import Html exposing (text) import Http import Json.Decode import Task import Time sequentialCmds : Cmd Msg -> List (Cmd Msg) -> Cmd Msg sequentialCmds cmd cmds = case cmds of [] -> cmd first :: others -> Cmd.batch [ cmd , Task.perform (\_ -> SequentialCmds first others) (Task.succeed ()) ] init : Cmd Msg init = sequentialCmds (Http.cancel getBrassicaOleraceaTracker) [ getBrassicaOleracea ] type Msg = GotBrassicaOleracea (Result Http.Error Json.Decode.Value) | SequentialCmds (Cmd Msg) (List (Cmd Msg)) | DoSomething update : Msg -> Cmd Msg update msg = case msg of GotBrassicaOleracea _ -> Cmd.none SequentialCmds cmd cmds -> sequentialCmds cmd cmds DoSomething -> Cmd.none main : Program () () Msg main = Browser.element { init = \_ -> init |> Tuple.pair () , view = \_ -> text "" , update = \msg _ -> update msg |> doSomething |> Tuple.pair () , subscriptions = \_ -> Sub.none } performImmediately : msg -> Cmd msg performImmediately msg = Task.perform (\_ -> msg) (Task.succeed ()) doSomething : Cmd Msg -> Cmd Msg doSomething cmd = let doSomethingCmd : Cmd Msg doSomethingCmd = Task.perform (always DoSomething) (Task.succeed ()) in cmd getBrassicaOleraceaTracker : String getBrassicaOleraceaTracker = "getBrassicaOleraceaTracker" getBrassicaOleracea : Cmd Msg getBrassicaOleracea = Http.request { method = "GET" , headers = [] , url = "https://en.wikipedia.org/api/rest_v1/page/summary/Brassica_oleracea" , body = Http.emptyBody , expect = Http.expectJson GotBrassicaOleracea Json.Decode.value , timeout = Nothing , tracker = Just getBrassicaOleraceaTracker }
Variables with other types of cmds such as Cmd.none do not cause this issue, which can be tested by changing the value of doSomethingCmd to Cmd.none.
Cmd.none
doSomethingCmd
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Quick Summary:
When a variable using
Task.perform
orTask.attempt
is created in the update function,Http.cancel
cancels http request in next update loop.SSCCE
https://ellie-app.com/6kdQ4HXVJ2ga1
Additional Details
Variables with other types of cmds such as
Cmd.none
do not cause this issue, which can be tested by changing the value ofdoSomethingCmd
toCmd.none
.The text was updated successfully, but these errors were encountered: