-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Watcher false triggering #1014
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
Comments
I think |
Yes, sometimes when you are adding dynamic components that rely on the same main object. I can say that this behaviour is new introduced after 0.12 and changelog have no reference to it, so I assume is a bug. |
It's actually not new. |
This is useful info, Evan, didn't know about this. Should probably be added somewhere in docs.. |
Thanks for looking into this Evan, maybe I'm getting confused but I'm not watching a non-existing property. Eg I start watching changes for 'my-value', with |
Yeah, adding a root level property triggers a re-evaluation of all watchers in that component. For normal watchers, if the previous value and the new value didn't change, the callback is not triggered; but deep watchers would trigger even if the value was the same (because it could be the same object but mutated). Maybe in this case the digest could be "shallow", i.e. only calls the callback when the value has changed. |
The "shallow" option sounds good, because for deeper level watchers it doesn't matter if the object has mutated or not, the only what matter if the watched value has changed. I don't mind if its a default behaviour or optional, but I would keep it always On in my code :) |
Thanks Evan :) |
Here I am again, reporting another bug :)
When $watch is set on some deeper level and the root is altered the callback is triggered. This happens only when deep is On and the some new value is being added.
It's difficult to explain, so please check the fiddle. There the $watch should not be triggered as 'some' value is not changed, but it does. Same happens using this.$watch.
The text was updated successfully, but these errors were encountered: