MithrilJS Stream.combine() violates atomic update semantics. #2623
Labels
Area: Stream
For anything dealing with Mithril streams
Type: Bug
For bugs and any other unexpected breakage
Mithril version: "next" branch (rev dca44b1)
Browser and OS: Ubuntu / Firefox 80
The following unit-test code (using tinytest) illustrates the issue:
The last two eq() assertions WRT numUpdates are violated (numUpdates will be reported as 2). This directly contradicts the manual which states that "Computed properties in Mithril are updated atomically: streams that depend on multiple streams will never be called more than once per value update[..]"
This issue can be fixed by making sure that combine() only pushes the change downstreams, after all of the mappers received the update that was advertised by the preceding invokation of _changing().
The following patch solves the issue for me (but may not be good enough for the mithril codebase, my js coding skills are limited).
This is only one half of the problem. Stream.combine() does not propagate the _changing() signal down-streams. This leads to more atomic semantics mis-behaviour when chaining Stream.combine(). See this unit test that still fails in spite of the fix above:
I can mitigate this problem by making stream.combine() forward the _changing() notification as follows:
Update: modified the first patch as it failed to pass the trivial test
The text was updated successfully, but these errors were encountered: