new Timer(interval)
Create a new Timer instance.
Parameters:
| Name | Type | Description |
|---|---|---|
interval |
Object | Number | The interval passed as a |
- Source:
Extends
Members
className
Get the className attribute. Used for CSS. Kebab cases the name
property by default.
- Inherited From:
- Source:
elapsed
Gets the elapsed the time as an interger.
- Source:
events
Get the events attribute.
- Overrides:
- Source:
isRunning
Returns true is the timer is running.
- Source:
isStopped
Returns true is the timer is not running.
- Source:
name
Get the name attribute. Uses the this.constructor.name by default.
- Inherited From:
- Source:
Methods
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
thisinstance.
- 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
thisinstance.
- 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
thisinstance.
- 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
thisinstance.
- Type
- Component
reset(fn) → {Timer}
Resets the timer.
Parameters:
| Name | Type | Description |
|---|---|---|
fn |
function | undefined | The interval callback. |
- Source:
Returns:
- The
Timerinstance.
- 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
Timerinstance.
- Type
- Timer
stop(fn) → {Timer}
Stops the timer.
Parameters:
| Name | Type | Description |
|---|---|---|
fn |
function | The stop callback. |
- Source:
Returns:
- The
Timerinstance.
- Type
- Timer