vue-hooks-plus
Version:
Vue hooks library
24 lines (23 loc) • 645 B
JavaScript
const vue = require("vue");
const useThrottleFn = require("../useThrottleFn");
const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
const useThrottleFn__default = /* @__PURE__ */ _interopDefaultLegacy(useThrottleFn);
function useThrottle(value, options) {
const throttled = vue.ref();
throttled.value = value.value;
const { run } = useThrottleFn__default.default(() => {
throttled.value = value.value;
}, options);
vue.watch(
value,
() => {
run.value();
},
{
immediate: true
}
);
return throttled;
}
module.exports = useThrottle;
;