vue-hooks-plus
Version:
Vue hooks library
23 lines (22 loc) • 442 B
JavaScript
import { ref, watch } from "vue";
import useThrottleFn from "../useThrottleFn";
function useThrottle(value, options) {
const throttled = ref();
throttled.value = value.value;
const { run } = useThrottleFn(() => {
throttled.value = value.value;
}, options);
watch(
value,
() => {
run == null ? void 0 : run();
},
{
immediate: true
}
);
return throttled;
}
export {
useThrottle as default
};