@cran/vue.use
Version:
Cranberry Vue Use Utilities
11 lines (10 loc) • 384 B
JavaScript
import { useRaf } from "./useRaf";
import { useRepeat } from "./useRepeat";
export function useInterval(handler, { paused = false, duration = 1000, } = {}) {
if (16 >= duration) {
return useRaf(handler, { paused, });
}
return useRepeat(function setupInterval(callback) {
return setTimeout(callback, duration);
}, clearTimeout, handler, { paused, });
}