Last updated

API / geotoolkit / util / Timer / Timer

Class: Timer

util.Timer.Timer

This class provides a Timer feature. It uses the browser's native capabilities to implement a Timer mechanism that will notify the given callback at the given rate. Calling code is responsible for stopping the timer to dispose it cleanly.

Table of contents

Constructors
Methods

Contents

Constructors

new Timer(interval, listener)

new Timer(interval?, listener?)

Parameters

Name Type Description
Optional intervalnumberinterval between ticks in ms. Default is 1000 ms.
Optional listenerTimerHandlerfunction to be called for each tick
Methods

getInterval

getInterval(): number

Return time interval in ms between ticks

Returns

number

time interval


isStarted

isStarted(): boolean

Return true if timer is started

Returns

boolean

if timer is started


setInterval

setInterval(interval): Timer

Sets interval of the timer in ms. The given interval will not be applied if the Timer is already started. One should stop and restart the timer to make this change effective.

Parameters

Name Type Description
intervalnumberinterval

Returns

Timer

this


setListener

setListener(listener): Timer

Sets listener

Parameters

Name Type Description
listenerTimerHandlerfunction to be called for each tick

Returns

Timer

this


start

start(): Timer

Start timer

Returns

Timer

this


stop

stop(): Timer

Stop timer

Returns

Timer

this