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(); // unsubscribeThe ctx object provides:
value— current MotionValue valueprogress— normalized 0–1wasActive— whether the threshold was active before this crossingdirection—"ascending" | "descending" | "none"velocity— current velocity
Options
Section titled “Options”| Option | Default | Description |
|---|---|---|
initialSync | true | Fire onEnter for already-active thresholds on subscribe |
emitExitsOnStop | false | Fire onExit for active thresholds when stop() is called |
bus | — | Fan-out CueBus for multiple subscribers |