Skip to content

Commit 973eda7

Browse files
committed
git: fix debounce decorator
1 parent 9998e79 commit 973eda7

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

extensions/git/src/decorators.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ function _throttle<T>(fn: Function): Function {
8080
export const throttle = decorate(_throttle);
8181

8282
export function debounce(delay: number): Function {
83-
return decorate((fn: Function) => {
84-
let timer: NodeJS.Timer;
83+
return decorate((fn, key) => {
84+
const timerKey = `$debounce$${key}`;
8585

8686
return function (...args: any[]) {
87-
clearTimeout(timer);
88-
timer = setTimeout(() => fn.apply(this, args), delay);
87+
clearTimeout(this[timerKey]);
88+
this[timerKey] = setTimeout(() => fn.apply(this, args), delay);
8989
};
9090
});
9191
}

0 commit comments

Comments
 (0)