Skip to content

Commit

Permalink
fix: debounce async function in SSR (#4340)
Browse files Browse the repository at this point in the history
  • Loading branch information
userquin committed Jun 29, 2023
1 parent 84aace7 commit ffa7318
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/vee-validate/src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,11 @@ export function debounceAsync<TFunction extends (...args: any) => Promise<any>,
return function (...args: Parameters<TFunction>) {
// Run the function after a certain amount of time
if (timer) {
window.clearTimeout(timer);
clearTimeout(timer);
}

timer = window.setTimeout(() => {
// @ts-expect-error timer is a number
timer = setTimeout(() => {
// Get the result of the inner function, then apply it to the resolve function of
// each promise that has been created since the last time the inner function was run
const result = inner(...(args as any));
Expand Down

0 comments on commit ffa7318

Please sign in to comment.