# RenderQueue

An abstract base class for managing the execution of rendering tasks.
It allows prioritizing updates and scheduling them using different strategies
(e.g., `requestAnimationFrame`, `requestIdleCallback`, `setTimeout`, or synchronous execution).

## Signatures

```ts
export declare abstract class RenderQueue implements Disposable {
    readonly [RenderQueueTypeId]: RenderQueueTypeId;
    readonly add: (key: unknown, task: () => void, dispose: () => void, priority: number) => Disposable;
    readonly [Symbol.dispose]: () => void;
}
```

## Why

Fine-grained DOM parts already know what to update; a queue determines when
those local mutations run. Keys coalesce superseded work without a virtual
tree traversal.

## Ownership and lifetime

A queue owns its pending callbacks. Disposing an entry cancels it; disposing
the queue cancels the active scheduler and drops all pending buckets. Render
Scopes dispose the callbacks they schedule.

## Ordering

Lower numeric priorities run first. Re-adding the same key and priority
disposes and replaces the previous entry.

## Property: [[computed:[RenderQueueTypeId]]]

Nominal evidence that this instance implements Typed's queue contract.

## Property: [[computed:[RenderQueueTypeId]]]: Why

Identifies renderer scheduling without selecting a concrete strategy.

## Property: [[computed:[RenderQueueTypeId]]]: Ownership and lifetime

Immutable metadata owned by the queue.

## Property: [[computed:[Symbol.dispose]]]

Cancels the active scheduler and forgets all queued entries.

## Property: [[computed:[Symbol.dispose]]]: Why

Render Scopes need deterministic scheduler cleanup.

## Property: [[computed:[Symbol.dispose]]]: Ownership and lifetime

Ends this queue's pending-work lifetime; already executed tasks are unaffected.

## Property: add

Adds a task to the render queue.

## Property: add: Why

Keyed replacement coalesces stale local DOM work before it runs.

## Property: add: Ownership and lifetime

The queue owns `task` and `dispose` until execution, replacement, returned
Disposable cancellation, or queue disposal.

## Examples

```ts
import { MixedRenderQueue, RenderPriority } from "@typed/template/RenderQueue"

const queue = new MixedRenderQueue()

// Add a high-priority synchronous task
queue.add("task1", () => console.log("High priority"), () => {}, RenderPriority.Sync)

// Add a medium-priority RAF task
queue.add("task2", () => console.log("Medium priority"), () => {}, RenderPriority.Raf(5))

// Add a low-priority idle task
queue.add("task3", () => console.log("Low priority"), () => {}, RenderPriority.Idle(1))
```
