Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upfeat: Add `watch` changes #314
Open
+18
−3
Conversation
@@ -14,7 +14,7 @@ | |||
|
|||
- **Usage:** | |||
|
|||
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. | |||
Watch a string expression or a computed function on the Vue instance for changes. The callback gets called with the new value and the old value. The string expression only accepts top-level data and component property names. For more complex expressions, use a function instead. |
This comment has been minimized.
This comment has been minimized.
privatenumber
Jul 22, 2020
I believe by "expression", they mean via function:this.$watch(() => this.c.d, ...)
And by "computed function on the Vue instance", they mean watch a computed property on the Vue instance via property name (string).
@yusufkandemir thank you for adding this fix! I've left a few comments for your consideration |
@@ -14,7 +14,7 @@ | |||
|
|||
- **Usage:** | |||
|
|||
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. | |||
Watch a string expression or a computed function on the Vue instance for changes. The callback gets called with the new value and the old value. The string expression only accepts top-level data and component property names. For more complex expressions, use a function instead. |
This comment has been minimized.
This comment has been minimized.
NataliaTepluhina
Jul 22, 2020
Collaborator
Let's rephrase it a bit to make an explanation less vague:
Suggested change
Watch a string expression or a computed function on the Vue instance for changes. The callback gets called with the new value and the old value. The string expression only accepts top-level data and component property names. For more complex expressions, use a function instead. | |
Watch a reactive property or a computed function on the Vue instance for changes. The callback gets called with the new value and the old value for the given property. We can only pass top-level `data`, `prop`, or `computed` property name as a string. For more complex expressions or nested properties, use a function instead. |
@@ -32,7 +36,17 @@ | |||
// do something | |||
}) | |||
// function | |||
// function for watching a deep path |
This comment has been minimized.
This comment has been minimized.
NataliaTepluhina
Jul 22, 2020
Collaborator
suggestion: let's replace deep path
with nested property
to reduce the ambiguity with deep
parameter
Suggested change
// function for watching a deep path | |
// function for watching a single nested property |
// function | ||
// function for watching a deep path | ||
this.$watch( | ||
// Only `this.c.d` will be watched |
This comment has been minimized.
This comment has been minimized.
NataliaTepluhina
Jul 22, 2020
Collaborator
nitpick: I believe with the change of code comment above, we could simply remove this explanation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
yusufkandemir commentedJul 21, 2020
Added explanation about breaking changes to component
watch
option and$watch
instance method. Updated the related explanation and added an example for clarification.See:
https://codepen.io/yusufkandemir/pen/KKVJKBQ
vuejs/vue-next#671
Current source code:
https://github.com/vuejs/vue-next/blob/288b4eab9e10187eb14d4d6d54dc9f077343a2a5/packages/runtime-core/src/apiWatch.ts#L308-L320