Skip to content

Add comments about $watch behavior with a function #1946

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

Merged
merged 1 commit into from
Jan 18, 2019

Conversation

posva
Copy link
Member

@posva posva commented Jan 17, 2019

I realised we are not explicit about this behaviour so I added some comments. I wonder if we should add a full example instead saying it in a comment. We could say that if we got a === 2 and b === 0 and we change both variables to b = 2; a = 0, the watcher won't get triggered

@phanan
Copy link
Member

phanan commented Jan 18, 2019

I think with the API doc already saying

Watch an expression or a computed function on the Vue instance for changes. The callback gets called with the new value and the old value. The expression only accepts dot-delimited paths. For more complex expressions, use a function instead.

your added comments should do the job well enough. Taking the liberty to merge now :)

@phanan phanan merged commit 4b816e2 into vuejs:master Jan 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants