Show:

A collection of timing utilities meant to translate the familiar setInterval, setTimeout timers to use Samsara's internal clock, which is backed by a requestAnimationFrame (RAF) loop. It also includes other helpful methods for debouncing.

Item Index

Methods

Methods

after

(
  • handler
  • numTicks
)
Function static

Wraps a function to be invoked after a specified number of Engine ticks.

Parameters:

  • handler Function

    Function to be executed

  • numTicks Number

    Number of frames to delay execution

Returns:

clear

(
  • handler
)
static

Cancel a timer.

Parameters:

debounce

(
  • handler
  • duration
)
Function static

Debounces a function for specified duration.

Parameters:

Returns:

every

(
  • handler
  • numTicks
)
Function static

Wraps a function to be invoked every specified number of Engine ticks.

Parameters:

  • handler Function

    Function to be executed

  • numTicks Number

    Number of frames per execution

Returns:

frameDebounce

(
  • handler
  • numFrames
)
Function static

Debounces a function for a specified number of Engine frames.

Parameters:

Returns:

setInterval

(
  • handler
  • interval
)
Function static

Wraps a function to be invoked at repeated intervals.

Parameters:

  • handler Function

    Function to be run at specified intervals

  • interval Number

    Time interval (in milliseconds)

Returns:

setTimeout

(
  • handler
  • duration
)
Function static

Wraps a function to be invoked after a certain amount of time. After a set duration has passed, it executes the function.

Parameters:

  • handler Function

    Function to be run after a specified duration

  • duration Number

    Time to delay execution (in milliseconds)

Returns: