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(apiWatch): control watch observation depth #9572

Open
wants to merge 19 commits into
base: minor
Choose a base branch
from

Conversation

Alfred-Skyblue
Copy link
Member

@Alfred-Skyblue Alfred-Skyblue commented Nov 8, 2023

RFC: vuejs/rfcs#597

fixed #9916

Support passing watch deep option as a number type, indicating the depth to which the object should be monitored. This allows control over the depth of object access in the watch function. In scenarios with large datasets, this can significantly improve performance.

Copy link

github-actions bot commented Nov 8, 2023

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 94.1 kB (+3.39 kB) 35.6 kB (+1.06 kB) 32 kB (+947 B)
vue.global.prod.js 151 kB (+3.39 kB) 54.8 kB (+1.09 kB) 48.9 kB (+872 B)

Usages

Name Size Gzip Brotli
createApp 54 kB (+3.27 kB) 20.9 kB (+1.04 kB) 19 kB (+878 B)
createSSRApp 57.4 kB (+3.27 kB) 22.2 kB (+1.04 kB) 20.2 kB (+867 B)
defineCustomElement 56.3 kB (+3.28 kB) 21.7 kB (+1.06 kB) 19.6 kB (+879 B)
overall 67.8 kB (+3.34 kB) 25.9 kB (+1.02 kB) 23.4 kB (+852 B)

@Alfred-Skyblue Alfred-Skyblue marked this pull request as ready for review November 20, 2023 09:35
@pikax pikax added the ✨ feature request New feature or request label Nov 22, 2023
@Alfred-Skyblue Alfred-Skyblue changed the base branch from main to minor November 29, 2023 04:35
@Alfred-Skyblue Alfred-Skyblue force-pushed the feat/apiWatch/depth branch 2 times, most recently from 9320020 to 1741978 Compare November 30, 2023 12:38
@yyx990803
Copy link
Member

Now have some conflicts after #9928

Also, I think it might be more concise to simply allow passing a number to deep, since the presence of depth implies deep: true:

// infinite depth
watch(src, () => {}, { deep: true })

// explicit depth
watch(src, () => {}, { deep: 1 })

@Alfred-Skyblue
Copy link
Member Author

Due to the consideration that users might have previously passed "deep" as a number in their usage, which was mistakenly treated as true in the previous implementation, if we now interpret "deep number" as referring to depth, the earlier practice of passing "deep" as a number would result in inconsistency. Of course, such usage was incorrect in the past. Should we take this into account? If we choose not to consider this, recognizing "deep" as referring to depth would be a more reasonable design approach.

@yyx990803
Copy link
Member

That's a good point. I think we can add a warning in a 3.4 patch that checks for deep with number values and warn users that it will be treated as depth in a future version.

@Alfred-Skyblue
Copy link
Member Author

Agreed. It's a good plan.

@wjp980108
Copy link

This feature is very useful for me. awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs Review
Status: No status
Development

Successfully merging this pull request may close these issues.

None yet

5 participants