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. 0.|
|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 restart it.|
|get set||repeat||Boolean||Timer repeatability. If true, the timer will be repeated invoked every period milliseconds.|
Timer Class Methods
Timer Instance Methods
|Timer(period: Number, callback: Function, args: Array)|
|Constructor for Timer.|
|restart(when: Number = null): Void|
|Reschedule a timer.|
|Start a timer running.|
|Stop a timer running.|
- Constructor for Timer. The timer is will not be called until start is called.
- 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.