Show:

A base class for Timer.

Constructor

Methods

_create

(
  • repeats
  • ms
  • fn
)
Object protected

Creates a collection of timer definitions.

Parameters:

  • repeats Object
  • ms Object
  • fn Object

Returns:

Object:

_decrementNextRunTime

(
  • tasks
)
protected

Subtracts the current time with the last run time. The result of this operation is subtracted with the task timeout.

Parameters:

  • tasks Object

_getNearestInterval

(
  • num
)
Number protected

Calculates the nearest interval by using the modulus of the argument with the interval as reference.

Parameters:

  • num Object

Returns:

_lazyDestroy

() protected

Checks if the timer is initialized and empty, then calls the clearTimeout function using the global interval id.

_lazyInit

() protected

Checks if the timer is initialized and contains a task, then calls the setTimeout function and stores the global interval id.

_loop

(
  • i
  • pendingTasks
  • length
)
protected

Goes through all pending tasks and initializes its timer or unregisters it depending on the task status.

Parameters:

  • i Object
  • pendingTasks Object
  • length Object

_resetNextRunTime

(
  • task
)
protected

Resets the next run time.

Parameters:

  • task Object

_runner

() protected

Gets the arguments to call the _loop method.

A.clearInterval

(
  • id
)
static

Cancels repeated action which was set up using setInterval function.

Parameters:

  • id Object

A.clearTimeout

(
  • id
)
static

Clears the delay set by setTimeout function.

Parameters:

  • id Object

A.setInterval

(
  • fn
  • ms
  • context
)
static

Calls a function repeatedly, with a fixed time delay between each call to that function.

Parameters:

  • fn Object
  • ms Object
  • context Object

A.setTimeout

(
  • fn
  • ms
  • context
)
static

Calls a function after a specified delay.

Parameters:

  • fn Object
  • ms Object
  • context Object

clearInterval

(
  • id
)

Cancels repeated action which was set up using setInterval function.

Parameters:

  • id Object

clearTimeout

(
  • id
)

Clears the delay set by setTimeout function.

Parameters:

  • id Object

intervalTime

(
  • newInterval
)
Number

Defines the fixed time delay between each interval.

Parameters:

  • newInterval Object

Returns:

isRepeatable

(
  • task
)
Boolean

Checks if the task is repeatable or not.

Parameters:

  • task Object

Returns:

Boolean:

register

(
  • repeats
  • fn
  • ms
  • context
  • args
)

Adds a new task to the timer.

Parameters:

  • repeats Object
  • fn Object
  • ms Object
  • context Object
  • args Object

run

(
  • task
)

Runs the task function.

Parameters:

  • task Object

setInterval

(
  • fn
  • ms
  • context
)

Calls a function repeatedly, with a fixed time delay between each call to that function.

Parameters:

  • fn Object
  • ms Object
  • context Object

setTimeout

(
  • fn
  • ms
  • context
)

Calls a function after a specified delay.

Parameters:

  • fn Object
  • ms Object
  • context Object

unregister

(
  • repeats
  • id
)

Removes a task from the timer.

Parameters:

  • repeats Object
  • id Object