@fogrexon/glyph-arena-loop

Injectable frame loop. See also package README.

Exports

Generated from the package's source when the docs are built — do not edit this table by hand.

NameKind
CancelRaftype
Clocktype
Looptype
LoopOptionstype
Raftype
RafCallbacktype
Timetype
createLoopfunction

createLoop(options)

const loop = createLoop({
  onFrame(time) { /* ... */ },
  maxDelta?, // optional, seconds; default 0.1
  clock?,   // optional
  raf?,     // optional
  cancelRaf?, // optional
});

loop.start();
loop.stop();
loop.isRunning; // boolean

Options

Time

All values are in seconds.

FieldDescription
elapsedTime since start()
deltaTime since the previous frame, capped at maxDelta (0.1 s by default)
frameFrame index

First frame: delta = 0, frame = 0.

Lifecycle

Error handling

If onFrame throws, isRunning becomes false, the error propagates, and no further frames are scheduled.

Late callbacks

After stop(), any rAF callback that was already scheduled but not yet run is ignored (the tick checks isRunning first). When cancelRaf is provided, stop also cancels the pending handle.