Timer

Source: AWT.js:1868

This class provides a timer that will launch a function at specific intervals


Constructor

new Timer( actionPerformed: function, interval: number, enabled?: boolean, ): Timer

Timer constructor

Parameters

  • actionPerformed (function) — The function to be triggered when the timer is enabled.
  • interval (number) — The interval between action calls, specified in milliseconds.
  • enabled (boolean, optional, default: false) — Flag to indicate if the timer will be initially enabled.

Instance Methods

actionPerformed(_thisTimer: module:AWT.Timer)

Here is where subclasses must define the function to be performed when this timer ticks.

Parameters

processTimer(_event: external:Event)

This is the method called by window.setInterval

Parameters

setEnabled(enabled: boolean, retainCounter?: boolean)

Enables or disables this timer

Parameters

  • enabled (boolean) — Indicates if the timer should be enabled or disabled
  • retainCounter (boolean, optional, default: false) — When true, the ticks counter will not be cleared

isRunning(): boolean

Checks if this timer is running

Returns

  • boolean

start(retainCounter?: boolean)

Starts this timer

Parameters

  • retainCounter (boolean, optional, default: false) — When true, the ticks counter will not be cleared

stop(retainCounter?: boolean)

Stops this timer

Parameters

  • retainCounter (boolean, optional, default: false) — When true, the ticks counter will not be cleared

Instance Fields

interval: number

The timer interval, in milliseconds

ticks: number

The ticks counter

timer: object

The object returned by window.setInterval

repeats: boolean

When true, the timer should repeat until stop is called