We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9998e79 commit 973eda7Copy full SHA for 973eda7
1 file changed
extensions/git/src/decorators.ts
@@ -80,12 +80,12 @@ function _throttle<T>(fn: Function): Function {
80
export const throttle = decorate(_throttle);
81
82
export function debounce(delay: number): Function {
83
- return decorate((fn: Function) => {
84
- let timer: NodeJS.Timer;
+ return decorate((fn, key) => {
+ const timerKey = `$debounce$${key}`;
85
86
return function (...args: any[]) {
87
- clearTimeout(timer);
88
- timer = setTimeout(() => fn.apply(this, args), delay);
+ clearTimeout(this[timerKey]);
+ this[timerKey] = setTimeout(() => fn.apply(this, args), delay);
89
};
90
});
91
}
0 commit comments