UNPKG

@mopinion/survey

Version:

Collect customer feedback with the Mopinion survey library

22 lines (21 loc) 684 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = useDebouncedCallback; var _hooks = require("preact/hooks"); function useDebouncedCallback(fn, wait) { var timeout = (0, _hooks.useRef)(); return (0, _hooks.useCallback)(function () { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var later = function later() { clearTimeout(timeout.current); fn.apply(void 0, args); }; clearTimeout(timeout.current); timeout.current = setTimeout(later, wait); }, [fn, wait]); } //# sourceMappingURL=useDebouncedCallback.js.map