FlushGate: its internal types
Interfaces
FlushGate
A Flush gate: what a binding registers its elements with and writes their values into, one per provider.
Properties
afterFlush
readonly afterFlush: (fn) => void;Call fn once, after the gate's next flush: the end of the Frame loop's tick, for a call
made in one, else the next Refresh frame's, so what was written before it is on the elements.
It schedules that flush if none is pending. A binding tells an animation's end here, as Motion's
onAnimationComplete comes with the final value set. One that throws is reported, and the rest
still run.
Parameters
fn
() => void
Returns
void
dispose
readonly dispose: () => void;Takes the gate off the Frame loop, cancels a pending frame and clears what it held. The Layer's Scope calls it.
Returns
void
flushPass
readonly flushPass: (pass) => void;Run a projection Measure pass now and apply exactly what it wrote before
returning. Only write()s made while
pass() runs are recorded; each recorded entry is projected and committed once, and
marked clean. Everything else stays dirty for its flush. A write made by an effect a sink's
hook runs (a Solid effect) takes the ordinary path. The Projection system calls it at the
end of a task, so a new layout never paints without its projection.
Parameters
pass
() => void
Returns
void
register
readonly register: (id, sink, values?) => () => void;Register an element under id with its sink. Returns an unregister fn
that removes the element from the accumulator (a subsequent write is a
no-op). values start its value-map, unflushed: drawn with its first write, so they never
commit alone.
Parameters
id
string
sink
values?
Readonly<Record<string, unknown>>
Returns
() => void
release
readonly release: (id, keys, restore?) => void;Hand keys back to the element's own style: drop each from the element's
value-map and schedule a flush, which writes restore[key] (CSS text) for a key it had
written, or else the inline value it overwrote, and tells the sink (onHeld). A key the
entry doesn't hold, or an unknown id, is a no-op. A binding releases a key back at its style
value, so a later style change shows at rest. A later write brings the key back.
Parameters
id
string
keys
readonly string[]
restore?
Readonly<Record<string, string>>
Returns
void
valueOf
readonly valueOf: (id, key) => Atom<unknown>;The element's value for id's key, live: an Atom set as each write that
changes it lands, so it's the value the next commit draws, before the Renderer projects it
(x as a number, not a transform). Set at the write, not the commit, so a value derived
from it (another key following it through a binding) is written in the same frame and
commits with it. undefined before the key's first write, and once it's released or the
element unregisters. One Atom for an id and a key, made on first ask, so per frame only the
keys asked for cost anything.
Parameters
id
string
key
string
Returns
Atom<unknown>
write
readonly write: (id, partial) => void;Merge partial into the element's value-map by key, mark it dirty, and
schedule a flush: the end of the Frame loop's tick, for a write made in one, or else the
next Refresh frame. A write for an unregistered (or unregistered-since) id
is a no-op.
Parameters
id
string
partial
Record<string, unknown>
Returns
void
FlushGateOptions
What a binding hands its flush gate.
Properties
batch
readonly batch: (apply) => void;Runs a flush's hooks together: calls apply, and returns once every update inside it has reached
the elements, before the gate commits. Solid 1 passes its batch, Solid 2 runs apply then
flush(), and React would pass flushSync, untried; a binding with nothing to batch passes
(apply) => apply(). Called at most twice a flush: once for the starting-style switches
(beforeFirstCommit) of the elements committing for the first time, before anything is read off the
elements; and once for the held keys (onHeld) of the elements whose held keys changed.
Parameters
apply
() => void
Returns
void
FlushSink
Where a flushed Patch is delivered: committed onto target with the Renderer's commit,
at flush time.
Properties
beforeFirstCommit?
readonly beforeFirstCommit?: () => void;Called once, just before the element's first commit in a frame flush (not a Measure
pass's flushPass), inside the binding's batch with every other element's switch that
flush: a binding drops its Starting style from its style prop here,
so its framework removes those keys and the commit writes the first frame in the same
Refresh frame, with no paint in between.
Returns
void
onCommit?
readonly onCommit?: (values) => void;Called once per frame in which the element's values were committed, after every commit of that
frame (Motion's onUpdate), with its values before
projection (x as a number). The object is the element's own, reused each call: valid during
the call, copied to keep. A Measure pass's commits are told at the frame flush after them, so
a frame tells each element once. A write it makes is the next frame's. A throw is reported,
and the others are still told.
Parameters
values
Readonly<Record<string, unknown>>
Returns
void
onHeld?
readonly onHeld?: (keys) => void;Called with every key the gate now holds on the element, each time that set changes: after the
gate restores a key it dropped, and before the commit that first
writes a key. A binding whose style prop reaches the element leaves these keys out of it,
so its framework never writes over Wardic's value (style is a key's fallback). Called in
the binding's batch, with every other element's whose keys changed that flush, so what the
binding changes reaches the element before the commit, a framework that applies an update later
(Solid 2) included.
Parameters
keys
readonly string[]
Returns
void
target
readonly target: unknown;The element the patch is committed onto.
Type Aliases
FlushGateServices
type FlushGateServices =
| Renderer.Renderer
| RefreshFrameSource.RefreshFrameSource
| FrameLoop.FrameLoop
| AtomRegistry.AtomRegistry;What a flush gate needs from its Environment: the Renderer, the Frame loop it flushes at the end of each tick of, and the RefreshFrameSource.