-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
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
splitOption
and splitOne
combined stays behind one event
#140
Comments
@HollandDM I believe you were the one that wrote the macros? Any idea what could be happening here? |
splitOption
and splitMatchOne
combined stays behind one eventsplitOption
and splitOne
combined stays behind one event
@HollandDM the macro is fine, it is |
So far I've reduced it to this: https://scribble.ninja/u/raquo/cyutyarybiqietcmigwstvmxnpoq val rx = Var(0)
// Bug
val splitOptionPlusSplitOneSignal = rx.signal
.splitOne(_ => "b")((_, _, vs) =>
vs.splitOne(_ => "a")((_, _, rx) =>
//rx.debugLog().observe(unsafeWindowOwner) // prints same values as Laminar renders to the UI
span(
text <-- rx.map(_.toString)
)
)
// .map(identity) // here is fine though
)
.map(_.map(identity)) // <<< adding this triggers bug
.flattenSwitch
// No bug
val splitOptionSignal = rx.signal
.splitOne(_ => "c")((_, _, bar) =>
bar.map(b =>
span(b.toString)
)
)
.map(_.map(identity))
.flattenSwitch My preliminarily tests show that Laminar is not necessary to trigger the issue, which is good, as that narrows it down a lot. I'll need to eliminate Laminar from the reproduction. Under the hood, all the Signal split* operators use the same implementation, so probably the problem is either there, or in Signal's flattenSwitch. I suspect the latter, but we'll see. Rather perplexing, not quite sure what it could be yet, TBH. I will look into this as soon as I can but it might take a week or two, it's not an easy bug, and I have a tough schedule right now. In the meantime, as a workaround, it seems that moving your signal.map to be inside the splitOne / splitOption bypasses this issue. If using splitOption, you can use its second ifEmpty param to specify the None case. |
…he previous signal active until after the new signal is activated. - This prevents situation where the common ancestor of the old and new signals is briefly stopped even though the demand for it never stopped. - Similarly for SwitchStream - This is part of the fix for #140. It happens to fix the reproduction in the issue, but is not a proper fix for the full issue.
…ust ensure to update that state if SplitSignal itself has no listeners. - This is an edge case, as typically SplitChildSignal is unlikely to have listeners when its own SplitSignal has none. - This is the proper general-purpose fix for #140
@arturaz Fantastic find, thanks! I was able to fix not one, but two unrelated issues thanks to this. Please try 17.2.1-M1, it should fix the original issue. Summary of the two issues:
Together, these two issues were causing SplitSignal to briefly stop due to lack of observers when switching from one The fixes for the two issues are:
Actually, either of these fixes alone would have been sufficient to fix the specific misbehaviour in the reproduction, but both are needed to properly fix the underlying problems in the general case. Migration: I guess it's possible that the flattenSwitch fix might expose a user's inadvertent reliance on this bug, but that's unlikely. The split bug seems exceptionally unlikely for anyone to depend on without realizing that it's a bug. |
I discovered a weird interaction between those two operators. See it in action:
https://scribble.ninja/u/arturaz/crhfsrdmulrwuvcotjevngtlsaoh
When you press
+
first time, first two labels does not update, whilst the next two work just fine.Upon successive presses the first two labels shows a value of previous event.
Repro code in case scribble goes down:
Discussion in Laminar Discord: https://discordapp.com/channels/1020225759610163220/1020225760075718669/1341370171331182662
The text was updated successfully, but these errors were encountered: