FrameLoop: its internal types
Interfaces
Run()
run's and runLast's shape: a run given a token can also end Superseded.
Call Signature
Run<F>(machine, sink): Effect<F>;run's and runLast's shape: a run given a token can also end Superseded.
Type Parameters
F
F extends Frame<unknown>
Parameters
machine
Machine<F>
sink
Sink<F>
Returns
Effect<F>
Call Signature
Run<F>(
machine,
sink,
options
): Effect<typeof Superseded | F>;run's and runLast's shape: a run given a token can also end Superseded.
Type Parameters
F
F extends Frame<unknown>
Parameters
machine
Machine<F>
sink
Sink<F>
options
Returns
Effect<typeof Superseded | F>
RunOptions
A run's options: the token it joins, so its caller can end it with others, and its timeline.
Properties
onFrameTimeline?
readonly onFrameTimeline?: boolean;Its start read from the frame timeline: it steps at the ticks' dt from its first frame (dtOf).
supersede?
readonly supersede?: Supersede;The token: Supersede.end on it ends every run that joined it.
Shape
The Frame loop's members: what FrameLoop gives.
Properties
afterTick
readonly afterTick: (hook) => Effect<void, never, Scope>;Calls hook at the end of every tick, with the tick's seconds, after every run's step and sink and
the continuations of the runs that settled in it, and again after each of its Late rounds, until the
Scope closes. Hooks run in the order they were added. A plain call, typed like a Sink, so a hook
that returns an Effect doesn't compile. A hook doesn't throw: one that does fails the tick, and with
it every run on the loop.
Parameters
hook
(dt) => undefined
Returns
Effect<void, never, Scope>
hint
readonly hint: (frameTime) => void;A binding's hint: its code runs inside the Refresh frame whose time is frameTime, after the
frame's tick, as a binding that renders in a frame callback of its own does (ADR-0071 decision 32).
Opens the Late window when a burst's last tick was this frame's (Clock.frameAt) or no burst runs
(no tick is coming this frame), so the runs added after it, in the rest of the callback and its
microtasks, take their Late step and are drawn in this frame, and a queued Measure pass runs as an after-tick one. With a
tick still to come in the frame, nothing: that tick is their first step. Idle, the Late step's dt is
the last tick's, or a nominal frame before any.
Parameters
frameTime
number
Returns
void
inLateWindow
readonly inLateWindow: () => boolean;Whether the Late window is open now: from a tick's first step until the microtask it queued at its end has run. What's written then is drawn in that tick's Refresh frame, after the tick.
Returns
boolean
run
readonly run: Run;Runs machine on the loop, handing each of its Frames to sink, from the loop's next tick until it
settles; added in the loop's Late window, from its Late step there. Succeeds with the settled Frame; a machine that never settles, chase, runs until it's
interrupted or superseded. Dies with the defect if its step or its sink throws. Interrupting it
removes it at once.
Given a Supersede token ({ supersede }), the run joins it, and Supersede.end(token) ends it at
once, as an interrupt would, but its fiber succeeds with Superseded.
runLast
readonly runLast: Run;run, but stepped after every run run added, in each tick: for a machine that reads what the
others' sinks wrote in the same tick. Among themselves, these runs step in the order they were added.
One added in the Late window takes no Late step: its first step is the next tick. One the tick
stepped steps again at dt 0 after a Late round that stepped a run run.
tickCount
readonly tickCount: () => number;How many ticks the loop has run: 0 before any. Neither a Late round nor a binding's hint window is a tick, so a run's Late step reads the count it was started at, and any step at a later tick a greater one.
Returns
number