Constructor
new Timers(scopeopt)
Creates a new instance of the Timers class.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
scope |
Object |
<optional> |
Scope within which the Timer object's callback functions are executed. |
- Source:
Members
(readonly) length :number
The number of Timer objects that are currently registered with the Timer
instance. Returns zero after disposal.
Type:
- number
- Source:
(readonly) numActive :number
The number of registered Timer objects that are currently active. Stopped
Timer objects are inactive, but paused are still considered active.
Returns zero after disposal.
Type:
- number
- Source:
paused :boolean
Pauses all Timer objects that are registered with the Timers instance.
Type:
- boolean
- Default Value:
- false
- Source:
Methods
add(timer, autoStartopt) → {rune.timer.Timer}
Adds the specified Timer object to the handler. Note that new Timer objects
should be created using the create method.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
timer |
rune.timer.Timer | Timer object to add. | ||
autoStart |
boolean |
<optional> |
true | If the Timer object is to be started automatically. |
- Source:
Returns:
- Type
- rune.timer.Timer
clear() → {undefined}
Removes, and deallocates all registered Timer objects. Does nothing after disposal.
- Source:
Returns:
- Type
- undefined
create(options, autoStartopt) → {rune.timer.Timer}
Creates and registers a new Timer object according to the specified
options object. The supplied options are not modified.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
options |
Object | Timer options. | ||
autoStart |
boolean |
<optional> |
true | If the Timer object is to be started automatically. |
- Source:
Returns:
The new Timer object.
- Type
- rune.timer.Timer
once(delay, callback, scopeopt) → {rune.timer.Timer}
Creates and starts a timer that invokes the callback once on completion.
Uses the same duration handling as create(). The callback receives the timer
and runs in the manager's scope unless another scope is supplied.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
delay |
number | Delay in milliseconds. | |
callback |
function | Function to invoke when the timer completes. | |
scope |
Object |
<optional> |
Callback scope; defaults to the manager's scope. |
- Source:
Returns:
The new timer, which can be paused or removed.
- Type
- rune.timer.Timer
remove(timer) → {boolean}
Removes the specified Timer object from the handler and activates the
deallocation process for that object. The timer is removed before disposal,
allowing its onAbort callback to safely modify the handler's timer list.
Parameters:
| Name | Type | Description |
|---|---|---|
timer |
rune.timer.Timer | Timer to remove. |
- Source:
Returns:
- Type
- boolean
reset() → {undefined}
Deletes Timer objects that have been completed and restarts Timer objects
that have not yet been completed.
- Source:
Returns:
- Type
- undefined