-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix(computedWithControl): allow deeply watching source #4786
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
Conversation
@@ -44,7 +47,7 @@ export function computedWithControl<T, S>( | |||
trigger() | |||
} | |||
|
|||
watch(source, update, { flush: 'sync' }) | |||
watch(source, update, { flush: 'sync', deep: true, ...options }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should deep
be true
by default? I think deep
is only needed in specific cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it is unexpected that computedWithControl
would not be deep by default when computed
is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A simple solution
I think exposing WatchOptions
for user customization is a good thing, but the use cases requiring deep
are few, and it is quite expensive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is a deep watcher expensive in a way that computed properties are not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, but what I want to express is that we should let users choose the way they want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I'm happy to change it back to shallow by default, but keeping the ability to override? Let me know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
computedWithControl
): deeply watch source8e7e4cd
to
ee31731
Compare
Before submitting the PR, please make sure you do the following
fixes #123
).Description
Fixes #4785
Make
computedWithControl
expose theWatchOptions
so user can override if desired, e.g. to deeply watch the source.Additional context
I noticed and removed a Vue 2 specific line in the code and docs, seeing as Vue 2 support was dropped in 12.0.0