Home HelloWorld! Doc API Examples GitHub

Timing Callback API

This describes the API of setPointCallback and setIntervalCallback.

setPointCallback

Invoke a callback whenever (timingObject.query().position === point). Implementation based on an internal timeout. If the timing object is updated in any way, the internal timeout is re-scheduled.

The default behaviour is to invoke callback at most once, similar to setTimeout. However, if option reapeat is specified setPointCallback will provide repeated callbacks on each occasion when timing object position is equal to point.

var handle = timingsrc.setPointCallback(timingObject, callback, point, options);
handle.cancel();
  • param: {Object} [timingObject] the timing object
  • param: {Function} [callback] callback to be invoked at correct time
  • param: {Float} [point] point on the timeline of the timing object
  • param: {Object} [options]
  • param: {Boolean} [options.repeat] repeated callbacks, default “false”
  • return: {Object} [handle] handle for cancelling the callback

setIntervalCallback

Invoke a callback whenever (timingObject.query().position === x) && ((x - offset) % length === 0). For example, if offset is 2 and length is 4, setIntervalCallback will invoke callbacks for points [... -2, 2, 6, 10, 14, ...]

var handle = timingsrc.setIntervalCallback(timingObject, callback, length, options);
handle.cancel();
  • param: {Object} [timingObject] the timing object
  • param: {Function} [callback] callback to be invoked at correct time
  • param: {Float} [length] length of interval between points
  • param: {Object} [options]
  • param: {Float} [options.offset] offset applied to all points, default 0.
  • return: {Object} [handle] handle for cancelling the callback