-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Unnecessary update of computed property and watcher call, triggered by update of dependent computed property, even when it is evaluated to the same primitive value #11884
Comments
In your example, I've actually ran in to this same issue and solved it similarly by watching a data property that gets updated through a secondary watcher. In the secondary watcher I compare the previous and current values for equality, and only update the data property when I've determined the values to be different. Edit: Oh, I think I see where you're coming from now. Yes I agree that since Edit 2: I also think there will be some amount of difficulty in fixing this though since computeds are queued for re-evaluation immediately (as in |
Yes, the main issue is update of This was just the very simple example to demonstrate, in real code I have computed property which parse single query string parameter and return primitive value. But because it depends on Still it would be nice, if Vue would be able to prevent such unnecessary updates, where simple equality |
This is expected, computed properties need to be reevaluated, |
Version
2.6.11
Reproduction link
https://jsfiddle.net/marcel_dancak/xr2q40Lp/19/
Steps to reproduce
Open console output in demo example. Click on UPDATE button and watch log messages in console.
What is expected?
After each click on UPDATE button, computed property 'c' is updated, but it's value is still the same number value. Computed property 'params' doesn't need to be updated, because it depends only on property 'c', which always has the same primitive value. Watcher on property 'c' is not triggered, and I would expect watcher on 'params' property to be not triggered as well.
What is actually happening?
Computed property 'params' is updated on each click.
I understand why 'c' watcher function is not called, and why watcher function on computed property returning 'the same' complex object is called, but I didn't expect computed property with the same primitive value result to cause updates of other computed properties.
The text was updated successfully, but these errors were encountered: