Add debounce
This commit is contained in:
parent
8120da422a
commit
d0fdd0276d
|
|
@ -0,0 +1,8 @@
|
|||
const debounce = (fn, time) => {
|
||||
let timerId;
|
||||
return function(...args) {
|
||||
const functionCall = () => fn.apply(this, args);
|
||||
clearTimeout(timerId);
|
||||
timerId = setTimeout(functionCall, time);
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue