Timer

Moduleejs.events
Namespace"ejs.events"
Definition class Timer
InheritanceTimer inherit Object

Timers manage the execution of functions at some point in the future.

Timers run repeatedly until stopped by calling the.


Properties

QualifiersPropertyTypeDescription
No properties defined

Timer Methods

QualifiersMethod
public set drift(enable: Boolean): Void
 Set the timer drift setting.
public get drift(): Boolean
 Get the current drift setting.
public get period(): Number
 Get the timer interval period in milliseconds.
public set period(period: Number): Void
 Set the timer period and reschedule the timer.
public restart(): Void
 Restart a stopped timer.
public stop(): Void
 Stop a timer running.
Timer(period: Number, callback: Function, drift: Boolean)
 Constructor for Timer.

Method Detail

set public drift(enable: Boolean): Void

Set the timer drift setting.

Description
If drift is false, reschedule the timer so that the time period between callback start times does not drift and is best-efforts equal to the timer reschedule period. The timer subsystem will delay other low priority events or timers, with drift equal to true, if necessary to ensure non-drifting timers are scheduled exactly. Setting drift to true will schedule the timer so that the time between the end of the callback and the start of the next callback invocation is equal to the period.
Parameters
enable: Boolean If true, allow the timer to drift

get public drift(): Boolean

Get the current drift setting.

Returns
True if the timer is allowed to drift its execution time due to other system events.

get public period(): Number

Get the timer interval period in milliseconds.


set public period(period: Number): Void

Set the timer period and reschedule the timer.

Parameters
period: Number New time in milliseconds between timer invocations.

public restart(): Void

Restart a stopped timer.

Description
Once running, the callback function will be invoked every.

public stop(): Void

Stop a timer running.

Description
Once stopped a timer can be restarted by calling.

Timer(period: Number, callback: Function, drift: Boolean)

Constructor for Timer.

Description
The timer is will not be called until.
Parameters
callback: Function Function to invoke when the timer is due.
period: Number Time period in milliseconds between invocations of the callback
drift: Boolean Set the timers drift setting. See [default: true]