Function: continuous()
function continuous<TState>(
sample: (context: ContinuousUpdateContext<TState>) => ComponentsManifest | EntityDirective | null,
options?: {
initial_state?: TState;
},
): ContinuousUpdate<TState>;
Defined in: livelink.clients/livelink.agent/sources/data/EventMapping.ts:164
Declare that an entity keeps moving between events, instead of writing one finished value.
The function is re-sampled on the pipeline's clock until a later event for the same id replaces
it, it returns null when the motion is over, and state is scratch space that survives those
replacements — which is exactly what a phase needs:
updates: event => {
const rpm = (event.payload as { rpm: number }).rpm;
return {
id: event.channel.split("/")[2],
update: continuous<{ angle_deg: number }>(
({ delta_seconds, state }) => {
// 360 degrees a turn, 60 seconds a minute.
state.angle_deg = (state.angle_deg + rpm * 6 * delta_seconds) % 360;
return { local_transform: { eulerOrientation: [state.angle_deg, 0, 0] } };
},
{ initial_state: { angle_deg: 0 } },
),
};
};
A motion runs until something replaces or stops it: a later event for the same id, a sample
returning null, a "hide" or "delete", or IngestionPipeline.clearContinuations. An
event whose updates returns null is not one of those — it means "this message said nothing
about this entity", so a topic carrying payloads of several shapes leaves the motion alone.
Wrapping is not ceremony: it is what keeps update: () => buildPatch(payload) — a plausible
slip, and a perfectly well-typed function — from silently installing a motion that never stops.
Type Parameters
| Type Parameter | Default type |
|---|---|
TState extends object | Record<string, never> |
Parameters
| Parameter | Type | Description |
|---|---|---|
sample | (context: ContinuousUpdateContext<TState>) => | ComponentsManifest | EntityDirective | null | Where the entity is now, given the time elapsed and its own state. |
options | { initial_state?: TState; } | initial_state for the value the entity's state starts at. |
options.initial_state? | TState | - |
Returns
ContinuousUpdate<TState>