The Wayback Machine - https://web.archive.org/web/20200723060626/https://github.com/vuejs/docs-next/pull/314
Skip to content
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

feat: Add `watch` changes #314

Open
wants to merge 5 commits into
base: master
from

Conversation

@yusufkandemir
Copy link

yusufkandemir commented Jul 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:

It was clashing with 'complex expression' in the example
@NataliaTepluhina NataliaTepluhina self-requested a review Jul 22, 2020
@@ -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.

@privatenumber

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).

Copy link
Collaborator

NataliaTepluhina left a comment

@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.

@NataliaTepluhina

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.

@NataliaTepluhina

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.

@NataliaTepluhina

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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.