-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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(runtime-core): add once
option to watch
#9034
Conversation
Size ReportBundles
Usages
|
fd27b69
to
9d2c180
Compare
It's a feature we need to consider if it's really necessary to merge into Vue core. I think we shouldn't put all of the things into Vue core unless the feature we want is used very frequently and widely (like |
Indeed, VueUse can achieve this functionality. However, in scenarios where we are encapsulating components within standalone libraries, we might not intend to incorporate additional third-party libraries. I've provided a list of the common use cases I frequently encounter:
Considering the points mentioned above, I believe the existence of the |
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.
LGTM from a code perspective, but we still need to wait for more perspectives about the necessity of this feature.
once
option to the watch functiononce
option to watch
Thanks for your contribution. It will be released as |
This reverts commit d573e50.
In certain scenarios, there are instances when I only need to use the
watch
function to monitor data changes once. For example, when detecting duplicate submissions of a form. Currently, my approach involves calling thestop
function within the callback, but this method lacks elegance. Hence, I have introduced anonce
parameter to thewatch
function. When theonce
parameter is set totrue
, it automatically stops monitoring after the initial change is detected.Now:
Expect: