How to use the uno-js.debounce function in uno-js

To help you get started, we’ve selected a few uno-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github unosquare / uno-react / src / hooks / useResolutionSwitch.ts View on Github external
export const useResolutionSwitch = (outerWidth = 1000, timeout = 500): [boolean] => {
    const [isMobileResolution, setMobileResolution] = React.useState(false);
    const handleResolutionChange = (): void => setMobileResolution(window.outerWidth < outerWidth);

    const listener = debounce(handleResolutionChange, timeout);

    React.useEffect(() => {
        window.addEventListener('resize', listener);
        handleResolutionChange();

        return (): void => window.removeEventListener('resize', listener);
    }, []);

    return [isMobileResolution];
};
github unosquare / uno-react / lib / hooks / useResolutionSwitch.js View on Github external
exports.useResolutionSwitch = function (outerWidth, timeout) {
    if (outerWidth === void 0) { outerWidth = 1000; }
    if (timeout === void 0) { timeout = 500; }
    var _a = React.useState(false), isMobileResolution = _a[0], setMobileResolution = _a[1];
    var handleResolutionChange = function () { return setMobileResolution(window.outerWidth < outerWidth); };
    var listener = uno_js_1.debounce(handleResolutionChange, timeout);
    React.useEffect(function () {
        window.addEventListener('resize', listener);
        handleResolutionChange();
        return function () { return window.removeEventListener('resize', listener); };
    }, []);
    return [isMobileResolution];
};

uno-js

JS/TS common used functions, zero dependencies

MIT
Latest version published 1 day ago

Package Health Score

70 / 100
Full package analysis