think/packages/client/src/helpers/debounce.tsx

10 lines
195 B
TypeScript

export function debounce(func, timeout = 300) {
let timer;
return (...args) => {
clearTimeout(timer);
timer = setTimeout(() => {
func.apply(this, args);
}, timeout);
};
}