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

refDebounced doesn't work with objects #3158

Closed
7 tasks done
HugeLetters opened this issue Jun 15, 2023 · 2 comments · May be fixed by #3969
Closed
7 tasks done

refDebounced doesn't work with objects #3158

HugeLetters opened this issue Jun 15, 2023 · 2 comments · May be fixed by #3969

Comments

@HugeLetters
Copy link

HugeLetters commented Jun 15, 2023

Describe the bug

debTest gets updated immediately instead of after a 1000ms delay.

const test = ref({ value: 'TEST' });
const debTest = refDebounced(test, 1000, { maxWait: 2000 });

Doing this works but is quite wordy with bigger objects.

const test = ref({ value: 'TEST' });
const debTest = refDebounced(
	computed(() => ({ value: test.value.value })),
	1000,
	{ maxWait: 2000 }
);

Reproduction

examples provided above

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (16) x64 AMD Ryzen 7 5700U with Radeon Graphics
    Memory: 2.19 GB / 15.33 GB
  Binaries:
    Node: 20.1.0 - C:\Program Files\nodejs\node.EXE
    npm: 9.6.4 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22621.1702.0), Chromium (114.0.1823.43)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @vueuse/core: ^10.1.2 => 10.1.2
    @vueuse/nuxt: ^10.1.2 => 10.1.2
    vue: ^3.3.2 => 3.3.4

Used Package Manager

npm

Validations

@HugeLetters
Copy link
Author

HugeLetters commented Jun 26, 2023

In case anyone stumbles upon this I've solved this later with - however if your object is deeply nested I assume this wouldn't work on deep properties.

const test = ref({ value: 'TEST' });
const debTest = refDebounced({ ...test }, 1000, { maxWait: 2000 });

@XavierChevalier
Copy link

XavierChevalier commented May 14, 2024

I have the same issue, and the way you are solving it doesn't work for me.
I think a deep parameter should be added, like watch function and deep clone the input ref.

XavierChevalier pushed a commit to XavierChevalier/vueuse that referenced this issue May 14, 2024
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 a pull request may close this issue.

2 participants