|Definition|| class Timer|
Timers manage the execution of functions at some point in the future.
Timers may run once, or they can be
scheduled to run repeatedly, until stopped by calling the stop() method. Timers are scheduled with a granularity
of 1 millisecond. However, many systems are not capable of supporting this granularity and make only best efforts
to schedule events at the desired time.
| get set ||drift||Boolean||The current drift setting. If drift is true, the timer is allowed to drift its execution time due to
other system events when attempting to optimize overall system performance.
If the drift value is set to false, the timer is scheduled so that the period between callback start
times does not gradually drift. When using non-drifting timers, the timer subsystem will
delay other low priority events or timers, if necessary to ensure non-drifting timers are scheduled exactly.
| get set ||onerror||Function||Error callback function for exceptions inside the Timer callback
The callback is invoked with the following signature:
function callback(error: Error): Void. |
| get set ||period||Number||Timer delay period in milliseconds. Changing a timer period will not reschedule a currently scheduled timer.
The period will be used to schedule the next invocation. To change the current period, stop the timer and
| get set ||repeat||Boolean||Timer repeatability. If true, the timer will be repeated invoked every period milliseconds.|
Timer Class Methods
(No own class methods defined)
Timer Instance Methods
- Constructor for Timer. The timer is will not be called until start is called.
|period: Number ||Delay in milliseconds before the timer will run.|
|callback: Function ||Function to invoke when the timer is due. The callback is invoked with the following signature: function callback(error: Error): Void.|
|args: Array ||Callback arguments.|
- Reschedule a timer. This will stop the timer if it is currently scheduled, then reschedule the timer.
If the when argument is provided, the timer period will be set before starting.
|when: Number ||Time period for when to next run the timer. [default: null]|
- Start a timer running. The timer will be repeatedly invoked if the repeat property is true, otherwise it
will be invoked once.
When the timer callback is invoked, it will be invoked with the value of "this" set to the timer unless the
function has bound a "this" value via Function.bind.
- The timer instance. This helps chaining. For example: var timer = Timer(1000, sayHello).start().
- Stop a timer running. Once stopped a timer can be restarted by calling start.