Skip to content

fix(runtime-core): support deep: false when watch reactive#9928

Merged
yyx990803 merged 4 commits intovuejs:mainfrom
yangxiuxiu1115:fix/watch
Dec 30, 2023
Merged

fix(runtime-core): support deep: false when watch reactive#9928
yyx990803 merged 4 commits intovuejs:mainfrom
yangxiuxiu1115:fix/watch

Conversation

@yangxiuxiu1115
Copy link
Contributor

fix #9916

@github-actions
Copy link

github-actions bot commented Dec 26, 2023

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 89.5 kB (+107 B) 34 kB (+53 B) 30.7 kB (+64 B)
vue.global.prod.js 146 kB (+107 B) 53.3 kB (+50 B) 47.6 kB (+26 B)

Usages

Name Size Gzip Brotli
createApp 49.8 kB (+107 B) 19.5 kB (+47 B) 17.8 kB (+39 B)
createSSRApp 53.2 kB (+107 B) 20.8 kB (+54 B) 19 kB (+44 B)
defineCustomElement 52.1 kB (+107 B) 20.3 kB (+48 B) 18.5 kB (+45 B)
overall 63.3 kB (+107 B) 24.4 kB (+55 B) 22.2 kB (+36 B)

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 26, 2023

CodSpeed Performance Report

Merging #9928 will not alter performance

Comparing RicardoErii:fix/watch (2bab130) with main (0695c69)

Summary

✅ 53 untouched benchmarks

@yangxiuxiu1115 yangxiuxiu1115 marked this pull request as draft December 26, 2023 16:11
@yangxiuxiu1115 yangxiuxiu1115 marked this pull request as ready for review December 26, 2023 16:15
@yangxiuxiu1115 yangxiuxiu1115 marked this pull request as draft December 26, 2023 16:23
@yangxiuxiu1115 yangxiuxiu1115 force-pushed the fix/watch branch 2 times, most recently from f459a71 to 2bab130 Compare December 26, 2023 16:32
@yangxiuxiu1115 yangxiuxiu1115 marked this pull request as ready for review December 26, 2023 16:32
return value
}

export function shallowTraverse(value: unknown) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be able to reuse traverse by adding a second argument:

traverse(value: unknown, shallow = false, seen?: Set<unknown>)

@Alfred-Skyblue
Copy link
Member

I added a depth option in #9572 to control the depth of watch listeners. When the object being watched is a shallowReactive, it should only listen to changes at the first level.

@yyx990803
Copy link
Member

@Alfred-Skyblue I like the depth idea, but it is a feature so I refactored this PR to use your depth-based traverse so we can land the fix in a patch sooner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected reactivity watching shallowReactive array

3 participants