Skip to content

observeCue

Subscribe to threshold crossings. Returns stop().

const stop = observeCue(motionValue, CUE, {
initialSync: true,
emitExitsOnStop: false,
bus: myBus,
onEnter: (key, ctx) => {},
onExit: (key, ctx) => {},
});
stop(); // unsubscribe

The ctx object provides:

  • value — current MotionValue value
  • progress — normalized 0–1
  • wasActive — whether the threshold was active before this crossing
  • direction — "ascending" | "descending" | "none"
  • velocity — current velocity
OptionDefaultDescription
initialSynctrueFire onEnter for already-active thresholds on subscribe
emitExitsOnStopfalseFire onExit for active thresholds when stop() is called
bus—Fan-out CueBus for multiple subscribers