-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Observer on computed property is firing when the computed value is unchanged #774
Comments
@adamlogic There's no way around it. We don't compute CPs until |
@wagenet Understood. Would you be open to a docs patch that clarifies this behavior? |
@adamlogic Certainly. It would definitely be worth highlighting the fact that CPs are lazily computed. It's totally worth it, but sometimes it catches people by surprise, especially if they are trying to use CPs when they should use observers. |
@wagenet Added a pull request. Curious if you have any examples handy of people using CPs when they should use observers. |
I once saw someone trying to do responsive style behavior in a CP, definitely an odd idea. The main thing you'll notice is that observers fire instantly, whereas bindings wait until the end of the runloop and CPs don't fire until requested. |
add docs regarding observers and computed properties (ref #774)
the removal of the implicit loading of a model per RFC #774 Co-authored-by: Aaron Chambers <[email protected]>
…opting into the removal of the implicit loading of a model per RFC #774 Co-authored-by: Aaron Chambers <[email protected]>
…ature [FEATURE] Add an optional feature "no-implicit-route-model" to allow the removal of the implicit loading of a model per RFC #774
…opting into the removal of the implicit loading of a model per RFC #774 Co-authored-by: Aaron Chambers <[email protected]> (cherry picked from commit e46ac3a)
Here is a jsfiddle to demonstrate the issue: http://jsfiddle.net/NfEgM/3/
When "set" is called on the "prop" property, the observer only fires if it is set with a new value. This is expected behavior.
The "computedProp" observer is firing every time, though, even when the computed value is the same. I believe this is unexpected behavior. The value is being recalculated because one of it's dependencies changes, but I think the observer should only fire if the actual value changes.
Is this a bug or intended behavior?
The text was updated successfully, but these errors were encountered: