vuejs / core

🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
https://vuejs.org/
MIT License
47.8k stars 8.35k forks source link

fix(reactivity): watchEffect should deduplicate multiple onCleanup calls for the same function #12394

Open shengxj1 opened 1 week ago

shengxj1 commented 1 week ago

fix #3341

github-actions[bot] commented 1 week ago

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 99.8 kB (-239 B) 37.9 kB (-59 B) 34.2 kB (-48 B)
vue.global.prod.js 158 kB (-239 B) 57.7 kB (-61 B) 51.3 kB (-90 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 47.1 kB (-103 B) 18.3 kB (-18 B) 16.8 kB (+34 B)
createApp 55.1 kB (-90 B) 21.3 kB (-19 B) 19.5 kB (-26 B)
createSSRApp 59.1 kB (-152 B) 23 kB (-28 B) 20.9 kB (-39 B)
defineCustomElement 60 kB (-88 B) 22.9 kB (-22 B) 20.8 kB (-14 B)
overall 68.9 kB (-193 B) 26.4 kB (-61 B) 24 kB (-122 B)
pkg-pr-new[bot] commented 1 week ago

Open in Stackblitz

@vue/compiler-core

``` pnpm add https://pkg.pr.new/@vue/compiler-core@12394 ```

@vue/compiler-dom

``` pnpm add https://pkg.pr.new/@vue/compiler-dom@12394 ```

@vue/compiler-ssr

``` pnpm add https://pkg.pr.new/@vue/compiler-ssr@12394 ```

@vue/compiler-sfc

``` pnpm add https://pkg.pr.new/@vue/compiler-sfc@12394 ```

@vue/reactivity

``` pnpm add https://pkg.pr.new/@vue/reactivity@12394 ```

@vue/runtime-core

``` pnpm add https://pkg.pr.new/@vue/runtime-core@12394 ```

@vue/runtime-dom

``` pnpm add https://pkg.pr.new/@vue/runtime-dom@12394 ```

@vue/server-renderer

``` pnpm add https://pkg.pr.new/@vue/server-renderer@12394 ```

@vue/shared

``` pnpm add https://pkg.pr.new/@vue/shared@12394 ```

vue

``` pnpm add https://pkg.pr.new/vue@12394 ```

@vue/compat

``` pnpm add https://pkg.pr.new/@vue/compat@12394 ```

commit: 6a13a05

skirtles-code commented 2 days ago

I'm unclear what the motivation is behind this change. Why do we need to deduplicate?

If the callback function is stateful (e.g. calling pop() on a stack) then calling it multiple times might be important. I don't know how realistic that kind of use case is in practice.