-
Notifications
You must be signed in to change notification settings - Fork 8
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
DerivedProperty calls derivation function with stale values #146
Comments
@samreid @jonathanolson thoughts on how to address this? |
I tried eliminating
The values are corrected because they are lazily grabbed from the property instead of cached. We still call the derivation multiple times even though it is no longer necessary, but I don't know if anything can be done about that. |
@jonathanolson and @samreid think the dynamic version proposed in #146 (comment) seems promising, but we would like to discuss it with @pixelzoom before proceeding. |
The "dynamic version" proposed in #146 (comment) is actually what I had in mind. Up to you whether you want to proceed or wait until I return from vacation to discuss. |
... though I'm not clear on why you would need "2 occurrences" of |
We still need a way to get the initial value, around line 50. |
Thanks for clarifying. @samreid feel free to proceed. This is blocking phetsims/beers-law-lab#210, which is blocking phetsims/beers-law-lab#209. |
Committed above, @pixelzoom can you please double check it? If all is well, you can close this issue and proceed on the beer's law lab issues. |
I reviewed the commit, and it looks OK to me. And I don't see any issues in bayes. So closing. |
This problem was identified while working on phetsims/beers-law-lab#210.
In some scenarios, DerivedProperty will call its derivation function with stale values. This can happens when one (or more) of its dependencies is a DerivedProperty.
Consider this example:
This console output demonstrates that
cProperty
's derivation function is first called with the old value ofaProperty
, then with the new value ofaProperty
:The problem is inherent in the approach used to "speed up" DerivedProperty. From its constructor:
The text was updated successfully, but these errors were encountered: