Timer(interval)

new Timer(interval)

Create a new Timer instance.

Parameters:
Name Type Description
interval Object | Number

The interval passed as a Number, or can set the attribute of the class with an object.

Source:

Extends

Members

elapsed :Number

The elapsed attribute.

Type:
  • Number
Source:

events :object

The events attribute.

Type:
  • object
Inherited From:
Source:

isRunning :boolean

The isRunning attribute.

Type:
  • boolean
Source:

isStopped :boolean

The isStopped attribute.

Type:
  • boolean
Source:

name :string

Get the name attribute.

Type:
  • string
Inherited From:
Source:

Methods

(static) defineName() → {string}

Define the name of the class.

Source:
Returns:
Type
string

callback(fn) → {*}

Helper method to execute the callback() function.

Parameters:
Name Type Description
fn function

The callback function.

Inherited From:
Source:
Returns:
  • Returns the executed callback function.
Type
*

emit(key) → {Component}

Emit an event.

Parameters:
Name Type Description
key string

The event id/key.

Inherited From:
Source:
Returns:
  • Returns this instance.
Type
Component

getAttribute(key) → {*}

Get an attribute. Returns null if no attribute is defined.

Parameters:
Name Type Description
key string

The attribute name.

Inherited From:
Source:
Returns:
  • The attribute value.
Type
*

getAttributes() → {object}

Get all the atttributes for this instance.

Inherited From:
Source:
Returns:
  • The attribute dictionary.
Type
object

getPublicAttributes() → {object}

Get only public the atttributes for this instance. Omits any attribute that starts with $, which is used internally.

Inherited From:
Source:
Returns:
  • The attribute dictionary.
Type
object

off(key, fn) → {Component}

Stop listening to an event.

Parameters:
Name Type Description
key string

The event id/key.

fn function | undefined

The listener callback function. If no function is defined, all events with the specified id/key will be removed. Otherwise, only the event listeners matching the id/key AND callback will be removed.

Inherited From:
Source:
Returns:
  • Returns this instance.
Type
Component

on(key, fn, onceopt) → {Component}

Start listening to an event.

Parameters:
Name Type Attributes Default Description
key string

The event id/key.

fn function

The listener callback function.

once boolean <optional>
false

Should the event handler be fired a single time.

Inherited From:
Source:
Returns:
  • Returns this instance.
Type
Component

once(key, fn) → {Component}

Listen to an event only one time.

Parameters:
Name Type Description
key string

The event id/key.

fn function

The listener callback function.

Inherited From:
Source:
Returns:
  • Returns this instance.
Type
Component

reset(fn) → {Timer}

Resets the timer.

Parameters:
Name Type Description
fn function | undefined

The interval callback.

Source:
Returns:
  • The Timer instance.
Type
Timer

setAttribute(key, value) → {void}

Set an attribute key and value.

Parameters:
Name Type Description
key string

The attribute name.

value *

The attribute value.

Inherited From:
Source:
Returns:
Type
void

setAttributes(values) → {void}

Set an attributes by object of key/value pairs.

Parameters:
Name Type Description
values object

The object dictionary.

Inherited From:
Source:
Returns:
Type
void

start(fn) → {Timer}

Starts the timer.

Parameters:
Name Type Description
fn function

The interval callback.

Source:
Returns:
  • The Timer instance.
Type
Timer

stop(fn) → {Timer}

Stops the timer.

Parameters:
Name Type Description
fn function

The stop callback.

Source:
Returns:
  • The Timer instance.
Type
Timer