Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upPort interactions do not preserve the order of Cmd.batch #799
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
process-bot
Dec 30, 2016
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!
Here is what to expect next, and if anyone wants to comment, keep these things in mind.
process-bot
commented
Dec 30, 2016
|
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it! Here is what to expect next, and if anyone wants to comment, keep these things in mind. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Dec 30, 2016
Contributor
This is not a bug. The specification of Cmd.batch doesn't promise any order preservation. See the comments in https://github.com/elm-lang/core/issues/730.
|
This is not a bug. The specification of Cmd.batch doesn't promise any order preservation. See the comments in https://github.com/elm-lang/core/issues/730. |
jvoigtlaender
closed this
Dec 30, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
fosskers
Apr 21, 2017
Just hit this problem. Definitely an unexpected result. It should be documented in Cmd.batch that no effect order is guaranteed, although mine appeared to be last-to-first.
The following gives the expected behaviour (notice the reverse):
-- | All tests.
tests : Cmd Event
tests = Cmd.batch <| List.reverse
[ H.send (Res "register/") (register host guy)
, H.send (Res "signin/") (signin host guy.uuid)
, H.send (Res "groups/ (A)") (groups host <| BlockSignin A "Foo" [guy.uuid])
, H.send (Res "groups/ (B)") (groups host <| BlockSignin B "Bar" [guy.uuid])
, H.send (Res "groups/ (C)") (groups host <| BlockSignin C "Baz" [guy.uuid])
]
fosskers
commented
Apr 21, 2017
•
|
Just hit this problem. Definitely an unexpected result. It should be documented in The following gives the expected behaviour (notice the -- | All tests.
tests : Cmd Event
tests = Cmd.batch <| List.reverse
[ H.send (Res "register/") (register host guy)
, H.send (Res "signin/") (signin host guy.uuid)
, H.send (Res "groups/ (A)") (groups host <| BlockSignin A "Foo" [guy.uuid])
, H.send (Res "groups/ (B)") (groups host <| BlockSignin B "Bar" [guy.uuid])
, H.send (Res "groups/ (C)") (groups host <| BlockSignin C "Baz" [guy.uuid])
] |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
fosskers
Apr 21, 2017
It may not be a bug, but the "feature behaviour" is unexpected, and documenting as such in old issues is helpful for future devs, I've found. The more people that report the behaviour, the better.
fosskers
commented
Apr 21, 2017
•
|
It may not be a bug, but the "feature behaviour" is unexpected, and documenting as such in old issues is helpful for future devs, I've found. The more people that report the behaviour, the better. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Apr 21, 2017
Contributor
So you say it "should be documented in Cmd.batch", but are unwilling to open an issue or PR that would work toward that goal? (The issue here is not working toward that goal of adding information to the documentation of Cmd.batch.)
|
So you say it "should be documented in |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
fosskers
commented
Apr 24, 2017
|
Relax Janis ;) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Am relaxing. |
lguminski commentedDec 30, 2016
•
edited
Edited 1 time
-
lguminski
edited Dec 30, 2016 (most recent)
I have noticed that Elm 0.18 does not respect the order of port interactions defined by
Cmd.batch. This is a problem for me as I am writing an Elm web client which receives data with a series of events (log file), parses it, and dispatches a series of event to a Javascript module through Elm ports.Cmd.batchlike thisin Javascript console produces
As you can see first Javascript subscription handlers of Port A have been called, and then Port B, which broke the original ordering
portA 5, portA 4, portB 3, portB 2, portA 1. Note: the test has been started after all subscriptions are in place (seeelm.ports.triggerTest.send(null);line inindex.htmlbelow). So the order of subscribing should not affect the observed behavior.How to reproduce
All files are in https://github.com/lguminski/ElmOrderingPortEventsTest repository. Clone them
and open http://localhost:8000 in your browser and check logs in Javascript console.
Files
OrderingPortEventsTest.elm
index.html