Skip to content

drive

Read as Markdown

drive(output, definition) returns an immutable PibblAnimationProgram. An accepted run leases the writable output for its entire lifetime, including surrounding waits. Competing writers fail unless playback requests replacement explicitly.

Creating this program does not update the signal or start playback. Pass it to usePlayback, then call play() to run it. The signal is the destination, not an observed input.

import { drive, tween, usePlayback, useSignal } from "@pibbl/core";
// Call inside a Pibbl component; invoke the returned function from an event handler.
function useMovement() {
const x = useSignal(0);
const movement = drive(x, tween({ from: 0, to: 100, duration: 300 }));
const playback = usePlayback(movement);
return { x, start: () => playback.play() };
}

drive replaces the former track name; there is no compatibility alias.

Related types: PibblAnimationDefinition, PibblAnimationProgram, and WritableSignal.

Binds one animation definition to one writable signal.

drive: <T>(output: WritableSignal<T>, definition: PibblAnimationDefinition<T>) => PibblAnimationProgram

Related API: drive, WritableSignal, PibblAnimationDefinition, PibblAnimationProgram.

A program that animates the supplied output signal. See PibblAnimationProgram.

WritableSignal

PibblAnimationDefinition

PibblAnimationProgram

View source — packages/core/src/lib/animation/program.ts:780

Read the Animation and scheduling companion for ownership, adaptation, failure modes, and verification. Agent start provides the version-selection workflow.

Documentation built with @pibbl/core 0.0.2, revision 2dccb19. ALPHA — NOT FOR PRODUCTION USE.