Skip to content

@jsvision/ui / runSpinner

Function: runSpinner()

runSpinner(frame, opts): () => void

Defined in: ui/src/feedback/run-spinner.ts:42

Advance frame by one every intervalMs, using the injectable one-shot timer (re-armed each tick).

Parameters

frame

Signal<number>

The caller-owned frame signal to advance (the same one handed to the Spinner).

opts

RunSpinnerOptions

intervalMs (default 80) + the timer seam.

Returns

stop() — clears the pending timer and stops advancing; safe to call more than once.

() => void

Example

ts
import { Group, Spinner, runSpinner, signal } from '@jsvision/ui';

const frame = signal(0);
const g = new Group();
g.add(new Spinner({ frame, label: 'Working…' }));

// `app.runtime` is the RuntimeAdapter from a running application.
const stop = runSpinner(frame, { timer: app.runtime, intervalMs: 80 });
// When the work finishes:
stop();