UNPKG

vuestic-ui

Version:
30 lines (29 loc) 705 B
import { isRef, watch, unref } from "vue"; import { d as debounce } from "../utils/debounce.js"; const useDebounceFn = (timeout) => { let callback = null; const createDebounced = () => { return debounce(() => { callback == null ? void 0 : callback(); callback = null; }, unref(timeout)); }; let debounced = createDebounced(); if (isRef(timeout)) { watch(timeout, () => { debounced = createDebounced(); }); } return { // todo check if we need to create proxy here debounced: (cb) => { callback = cb; debounced(); }, cancel: () => debounced.cancel() }; }; export { useDebounceFn as u }; //# sourceMappingURL=useDebounce.js.map