StringTune/Docs

API Reference

frameDOM

Read/write scheduler used by the runtime to separate measure and mutate work.

frameDOM

frameDOM is a tiny scheduler with two queues:

  • measure(fn)
  • mutate(fn)

Public status

frameDOM is exported by the package root and is valid advanced integration surface.

What it does

It lets code queue work into two phases:

  1. measure
  2. mutate

Then flush() runs the measure queue first and the mutate queue second.

That is the same read/write split the main runtime uses.

API shape

TypeScript
frameDOM.measure(() => {});
frameDOM.mutate(() => {});
frameDOM.flush();

How it works

Important current behavior:

  • measure(...) and mutate(...) only queue work
  • schedule() just marks the scheduler as dirty
  • actual execution happens on flush()
  • the main StringTune loop already calls flush()

When to use it

Use it when:

  • you need extra DOM reads outside a module hook
  • you need extra DOM writes outside a module hook
  • you want custom code to stay aligned with the runtime’s phase order

When not to use it

If you are already inside:

  • onScrollMeasure(...)
  • onMouseMoveMeasure(...)
  • onMutate(...)

then you usually do not need to queue more work through frameDOM.

Practical note

For most modules, lifecycle hooks are the main integration surface and frameDOM is the escape hatch.