Object: Timer

The Timer object represents a one-shot or repeating timer. It can be scheduled for a specific amount of time, and will call a provided function after that interval. Optionally, the timer can be configured as a recurring timer.

Timer objects can be canceled to prevent any further callbacks.

Timers fire during X-Plane's flight loop callbacks, ocurring before physics.

Properties

Methods

Events

None.

Example

// A one shot timer:
> timer = new Timer(() => console.log("Fired!"));
undefined
> timer.scheduleOnce(0.1);
undefined
Fired!

// A repeating timer:
> timer2 = new Timer(() => console.log("Repeat fire!"));
undefined
> timer2.scheduleRepeat(0.1);
undefined
Repeat fire!
Repeat fire!
Repeat fire!
> timer2.delay
100
> timer2.cancel()
undefined

References