11 lines
263 B
TypeScript
11 lines
263 B
TypeScript
|
export const useBounce = (): Function => {
|
||
|
let bounce: NodeJS.Timeout;
|
||
|
|
||
|
return function (callback: Function, timeout: number = 400) {
|
||
|
clearTimeout(bounce);
|
||
|
bounce = setTimeout(() => {
|
||
|
callback();
|
||
|
}, timeout);
|
||
|
};
|
||
|
};
|