ensure-debounce.ts
export function debounceManager(debounceTime: number): { ensureDebounce: (fn: Function) => void } {
var curHandle: number | null = null;
return {
ensureDebounce: (fn: Function) => {
if (curHandle != null) {
clearInterval(curHandle);
curHandle = null;
}
curHandle = setTimeout(() => {
fn();
}, debounceTime);
}
}
}