-
-
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
Re-evaluate signal's current value when restarting signal #43
Labels
Comments
This was referenced Jan 5, 2021
vic
added a commit
to vic/Airstream
that referenced
this issue
Jan 27, 2021
This branch changes Signal.onStop to make it forget its internal memory when all observers have been removed. Causing it to re-compute its "initialValue" again if the Signal is re-started. This way, dependent signals (eg, MapSignal) can ask their parent signal for the latest value upon restarting, and elements that read these dependent signals can now observe the correct state when re-mounted. Fixes raquo#43
davoclavo
pushed a commit
to deal-engine/Airstream
that referenced
this issue
Mar 18, 2021
This branch changes Signal.onStop to make it forget its internal memory when all observers have been removed. Causing it to re-compute its "initialValue" again if the Signal is re-started. This way, dependent signals (eg, MapSignal) can ask their parent signal for the latest value upon restarting, and elements that read these dependent signals can now observe the correct state when re-mounted. Fixes raquo#43
davoclavo
pushed a commit
to deal-engine/Airstream
that referenced
this issue
Mar 19, 2021
This branch changes Signal.onStop to make it forget its internal memory when all observers have been removed. Causing it to re-compute its "initialValue" again if the Signal is re-started. This way, dependent signals (eg, MapSignal) can ask their parent signal for the latest value upon restarting, and elements that read these dependent signals can now observe the correct state when re-mounted. Fixes raquo#43
fabianhjr
pushed a commit
to fabianhjr/Airstream
that referenced
this issue
May 18, 2021
This branch changes Signal.onStop to make it forget its internal memory when all observers have been removed. Causing it to re-compute its "initialValue" again if the Signal is re-started. This way, dependent signals (eg, MapSignal) can ask their parent signal for the latest value upon restarting, and elements that read these dependent signals can now observe the correct state when re-mounted. Fixes raquo#43
raquo
added a commit
that referenced
this issue
Dec 4, 2021
- This is a big change to fix #43 - Not quite complete yet, still need to work on various timing streams - Also removed some Future-related stuff that I don't want to support anymore
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, when you first start
x100signal
, it initializes its initial value (not a typo – signals' initial values are lazy) by pulling the current value ofx10signal
, which initializes the initial value ofx10signal
by pullingstate.signal
's current value. However, if afterwards you stopx100signal
, then after some time start it again, this pulling-current-value chain will not happen,x100signal
will simply start listening to newx10signal
updates from this point on. This means that ifstate
was updated whilex100signal
was stopped,x100signal
will not receive this update when it's started again.This is documented behavior – observables are lazy, so you shouldn't stop the ones you care about – but it would be more useful if
x100signal
could recursively pull its parent's current value not just when initializing the signal's initial value, but every time it's started.This would have convenient practical effects in Laminar when re-mounting unmounted elements – those would be brought up to date when they're re-mounted.
However, very importantly, this measure can't cancel out laziness per se, and specifically this can not possibly replay the EventStream events that fired while the signal was stopped, so we will not be able to pull an updated current value for signals that depend on event streams, such as
stream.foldLeft(...)
orstream.startWith(...)
.This caveat will make undesired behavior more rare, but more specialized and harder to debug. However, it is probably a good tradeoff, since it should be more obvious that any events you've missed will not be re-emitted, than how your signal won't pull a parent's current value when it's reactivated.
gitter context
The text was updated successfully, but these errors were encountered: