export const useDefer = (maxFrame: number = 1000) => {
    const frame = ref(1)
    let rafId: number

    function updateFrame() {
        rafId = requestAnimationFrame(() => {
            frame.value++
            if (frame.value > maxFrame) return
            updateFrame()
        })
    }

    onMounted(() => {
        updateFrame()
    })
    onUnmounted(() => {
        cancelAnimationFrame(rafId)
    })
    return (n: number) => {
        return frame.value >= n
    }
}