Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
335 B
0
Indexable
Never
import { getDefaultTicker } from "~/librairies/Ticker.js";

/**
 * @param {Function} fn
 * @param {undefined|Number} priority
 */
export const useFrame = (fn, priority = undefined) => {
  const ticker = getDefaultTicker();

  onMounted(() => {
    ticker.add(fn, priority);
  });

  onUnmounted(() => {
    ticker.remove(fn);
  });
};