library_components/composables/useBounce.ts
2024-07-05 14:22:31 +02:00

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);
};
};