export const DelayedFunction = (fun, delay) => {
    let ref = null;
    const schedule = (...args) => {
        ref = setTimeout(() => {
            fun.apply(null, args);
            ref = null;
        }, delay);
    };
    const cancel = () => {
        if (ref !== null) {
            clearTimeout(ref);
            ref = null;
        }
    };
    return {
        cancel,
        schedule
    };
};
//# sourceMappingURL=DelayedFunction.js.map