watchDebounced return incorrect oldValue
Describe the bug
There is difference in how will work refDebounced + watch and watchDebounced.
Let's say we have a series of value changes:
- initial value is
1 - then value is changed to
2 - then to
3.
- If you will use
refDebounced+watch,oldValueis the value of reference before modifications, i.e.1(which is expected) - If you will use
watchDebounced,oldValueis the value of last modifiction, i.e.2(which is unexpected).
That's because watchDebounced simply filter all events until the last one before time expire.
Reproduction
https://stackblitz.com/edit/vitejs-vite-db5xkj/?file=src%2FApp.vue
System Info
System:
OS: Windows 10 10.0.22621
CPU: (8) x64 Intel(R) Core(TM) i7-2670QM CPU @ 2.20GHz
Memory: 3.79 GB / 15.91 GB
Binaries:
Node: 18.15.0 - C:\Program Files\nodejs\node.EXE
Yarn: 3.6.1 - E:\storefront\vc-theme-b2b-vue\node_modules\.bin\yarn.CMD
npm: 9.5.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.22621.2283.0), Chromium (117.0.2045.31)
Internet Explorer: 11.0.22621.1
npmPackages:
@vueuse/components: ^10.1.2 => 10.4.1
@vueuse/core: ^10.1.2 => 10.4.1
@vueuse/head: ~0.9.8 => 0.9.8
vue: ^3.3.4 => 3.3.4
Used Package Manager
yarn
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a VueUse issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- [X] The provided reproduction is a minimal reproducible example of the bug.
Hey guys, any news on that?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Adding here that not only the problem is still there, but the workaround (refDebounced + watch) does not work for reactive objects.
@rafaellehmkuhl Please create separate issue with mention of this one to catch attention of the team. I don't believe they review closed issues
I have the same bug. @antfu can you re-open?
Can you share an up to date reproduction @mesqueeb?