linked-controls/js/hooks.js
function useThrottle(fun, timeout, changes) {
    if (changes === void 0) { changes = []; }
    // Create the ref to store timer.
    var timer = react_1.useRef(null);
    function cancel() {
        if (timer.current) {
            clearTimeout(timer.current);
            timer.current = null;
        }
    }
    // Register the 
    react_1.useEffect(function () { return cancel; }, changes);
    return function () {
        var _this = this;
        var args = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            args[_i] = arguments[_i];
        }
        cancel();
        timer.current = setTimeout(function () {
            timer.current = null;
            fun.apply(_this, args);
        }, timeout);
    };
}
function useThrottle(fun, timeout, changes) {
    if (changes === void 0) { changes = []; }
    // Create the ref to store timer.
    var timer = react_1.useRef(null);
    function cancel() {
        if (timer.current) {
            clearTimeout(timer.current);
            timer.current = null;
        }
    }
    // Register the 
    react_1.useEffect(function () { return cancel; }, changes);
    return function () {
        var _this = this;
        var args = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            args[_i] = arguments[_i];
        }
        cancel();
        timer.current = setTimeout(function () {
            timer.current = null;
            fun.apply(_this, args);
        }, timeout);
    };
}
function useThrottle ( fun , timeout , changes ) { if ( changes === void 0 ) { changes = [ ] ; } // Create the ref to store timer. var timer = react_1 . useRef ( null ) ; function cancel ( ) { if ( timer . current ) { clearTimeout ( timer . current ) ; timer . current = null ; } } // Register the  react_1 . useEffect ( function ( ) { return cancel ; } , changes ) ; return function ( ) { var _this = this ; var args = [ ] ; for ( var _i = 0 ; _i < arguments . length ; _i ++ ) { args [ _i ] = arguments [ _i ] ; } cancel ( ) ; timer . current = setTimeout ( function ( ) { timer . current = null ; fun . apply ( _this , args ) ; } , timeout ) ; } ; }
Delays function calls for a given timeout.
Delays function calls for a given timeout .