Skip to content

createCueBus

Shared store for fan-out. Pass bus to observeCue, then subscribe.

import { createCueBus, defineCue, observeCue } from 'motion-cues';
const bus = createCueBus();
const FLOOD = defineCue("flood", { half: 0.5, full: 1 });
observeCue(progress, FLOOD, { bus });
bus.subscribe(() => {
if (bus.has("flood", "half")) track("halfway");
if (bus.has("flood", "full")) startNextPhase();
});
bus.has("cue-name", "threshold"); // boolean
bus.get("cue-name"); // { triggered: Set<string> }
bus.reset("cue-name"); // clear triggered keys
bus.subscribe(() => {}); // returns unsubscribe fn