Skip to content

playAnimation

Read as Markdown

Import from @pibbl/core/machines/animation or pibbl/machines/animation. playAnimation(factory, options?) returns a task for invoke.task. The factory receives the entry’s context, event, input, abort signal, and send function, and returns an ordinary Pibbl animation program.

Finite playback resolves after the scheduler’s finish event and can select invoke.onDone. Infinite playback runs until cancellation. On state exit the adapter disposes only its owned controller. Cancellation does not select completion or error transitions. Animation sampling still uses Pibbl’s shared scheduler.

Options provide an optional debug name and the existing animation writer-conflict policy. The default rejects conflicts; simultaneous states/tasks do not silently blend shared signal outputs or cancel unrelated writers.

See machine animation and machine types.

Related types: MachineAnimationOptions, MachineAnimationProgramFactory, MachineTask.

Adapts a Pibbl animation program into state-owned cancelable machine work.

A finite program resolves the state invocation after the animation scheduler delivers its finish event, allowing the invocation’s onDone transition to run. Repeating programs remain active until their state exits or the actor stops. Cancellation disposes only this adapter’s playback and never sends a completion or error transition.

playAnimation: <Context, Event extends MachineEvent, Input>(program: MachineAnimationProgramFactory<Context, Event, Input>, options?: MachineAnimationOptions) => MachineTask<Context, Event, Input, void>

Related API: playAnimation, MachineEvent, MachineAnimationProgramFactory, MachineAnimationOptions, MachineTask.

  • Context — Context captured when this state entry began.

  • Event — Event type accepted by the owning machine.

  • Input — Input captured by the owning machine actor.

  • program — Factory that creates the program for this state entry.

  • options — Playback conflict policy and diagnostic label.

A task suitable for a state’s invoke.task field.

running: {
invoke: {
task: playAnimation(({ input }) =>
repeat(drive(input.frame, input.animations.run), { iterations: Infinity }),
),
},
}

MachineAnimationOptions

View source — packages/core/src/features/machines/animation.ts:80

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.