Pixel Data JS - v0.40.1
    Preparing search index...

    Function makeRenderQueue

    • Creates a debounced render queue using requestAnimationFrame. This utility ensures that a callback is executed exactly once right before the next visual frame, regardless of how many times the trigger is called synchronously. It safely prevents layout thrashing and redundant computations.

      Parameters

      • cb: () => void

        The function to execute on the next animation frame.

      Returns { cancel(): void; (): void }

      A trigger function that schedules the callback. It includes a .cancel() method to abort the pending frame. *

      let renderQueue = makeRenderQueue(() => {
      console.log('DOM updated!')
      })
      * // Calling this multiple times synchronously...
      renderQueue()
      renderQueue()
      renderQueue()
      * // ...will only result in one 'DOM updated!' log on the next frame.
      // Canceling a scheduled render (e.g., when a component unmounts)
      let trigger = makeRenderQueue(updateLayout)
      trigger()
      trigger.cancel() // The callback will not execute