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

10 lines
195 B
TypeScript
Raw Normal View History

2022-02-20 11:51:55 +00:00
export function debounce(func, timeout = 300) {
let timer;
return (...args) => {
clearTimeout(timer);
timer = setTimeout(() => {
func.apply(this, args);
}, timeout);
};
}