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): support passing the number type for deep to control the watch depth #9572

Merged
merged 25 commits into from
Aug 2, 2024

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 95.4 kB (+5.24 kB) 36.4 kB (+1.82 kB) 32.7 kB (+1.6 kB)
vue.global.prod.js 153 kB (+6.21 kB) 56.1 kB (+2.09 kB) 50 kB (+1.94 kB)

Usages

Name Size Gzip Brotli
createApp 53 kB (+3.35 kB) 20.6 kB (+1.11 kB) 18.8 kB (+988 B)
createSSRApp 56.9 kB (+3.73 kB) 22.2 kB (+1.26 kB) 20.2 kB (+1.12 kB)
defineCustomElement 55.3 kB (+3.35 kB) 21.4 kB (+1.15 kB) 19.5 kB (+995 B)
overall 66.5 kB (+3.4 kB) 25.6 kB (+1.13 kB) 23.3 kB (+1.07 kB)

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

@Alfred-Skyblue Alfred-Skyblue changed the title feat(apiWatch): control watch observation depth feat(apiWatch): support passing the number type for deep to control the watch depth Jun 28, 2024
@hubdidub
Copy link

I don't want to annoy you guys, but I'm curious, since 3.5 already has some alpha releases.. is there still a chance this goes into 3.5? I'd love to use this feature 😀

@yyx990803 yyx990803 merged commit 22f7d96 into vuejs:minor Aug 2, 2024
7 checks passed
@Alfred-Skyblue Alfred-Skyblue deleted the feat/apiWatch/depth branch August 2, 2024 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants