question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Side effects and ordering in flyd.on

See original GitHub issue
var 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:open
  • Created 7 years ago
  • Reactions:1
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
garkincommented, Nov 1, 2017

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.

1reaction
garkincommented, Nov 1, 2017

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 the updateDeps() and in the findDeps()) 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found