Side effects and ordering in flyd.on
See original GitHub issuevar x = flyd.stream()
flyd.on(console.log.bind(console,'one'),x)
flyd.on(console.log.bind(console,'two'),x)
flyd.on(console.log.bind(console,'three'),x)
x('fire')
This gives the result
three fire
two fire
one fire
This seems counter intuitive to me and caused some issues for me. Is there any rationale for this behavior? Could we change it? This seems like a major design decision, and if this was intended, I cannot understand the rationale.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:13 (8 by maintainers)
Top Results From Across the Web
paldepind/flyd: The minimalistic but powerful ... - GitHub
Use on for doing side effects in reaction to stream changes. Use the returned stream only if you need to manually end it....
Read more >The emotional and mental health impact of the murder ... - PNAS
SignificanceOn May 25, 2020, George Floyd, an unarmed Black American male, ... larger increases in depression and anxiety symptoms after Floyd's death.
Read more >How George Floyd Died, and What Happened Next
Mr. Floyd, a Black man, died in May 2020 after being handcuffed and pinned ... It said that officers ordered him to step...
Read more >Side Effects of Amino Acid Supplements - PMC - NCBI
Then I will examine in an alphabetic order what side effects can be induced ... Floyd JC, Jr, Fajans SS, Conn JW, Knopf...
Read more >The monumental impact of George Floyd's death on Black ...
"Black people were the ones that were sort of the most mobilized to ... A mural painted by Kenny Altidor depicts George Floyd...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The problem is a backward compatibilty. It will change the order of execution for already existing programs. It would be a breaking change.
If we forget about that - it could be usefull for simple cases. Could be planned for a major version increment.
On the second thought, in complex and dynamic topologies it won’t help. Order there won’t be obvious from the declaration, and you should not rely on it.
This is a result of topological sort of the dependency graph. It’s needed for atomic updates.
For example in this case sorted nodes array will look like
[OnBbb, bbb, OnCc, cc, bb, b, c, d]
. Array with sort results should always be iterated in reverse to the build order due the nature of such sort. This is why you could not change iteration order in the unwrapping loop.But it is possible to reverse node children iteration order during build. (both
for(of [...listeners])
loops in theupdateDeps()
and in thefindDeps()
) In this case you will get following order:And sorted nodes:
[d, OnCc, cc, c, OnBb, bbb, bb, b]
. This will result in the sort being sometimes closer to the natural order of children.