ArcGIS for Developers

QPTimer QML Type

(DEPRECATED) Singleton timer utility. More...

Import Statement: import ArcGIS.AppFramework.Promises 1.0


Detailed Description

This component is in the process of being deprecated, and should not be used. Instead, use the JavaScript implementation for promises.

The QPTimer component provides a simple timer functionality that can be included in other functions with a minimum of difficulty. This function is a singleton, meaning that it does not need to be instantiated to be used.

This component is designed to be used alongside promises, but can be used outside of them for any situations where creating separate timer objects would be inefficient.

This code sample demonstrates the functionality of QPTimer, setting two adjacent timers and comparing the two.

Item {
        function test_setTimeout() {
                var count1 = 0, count2 = 0;
                var id1 = QPTimer.setTimeout(function(){
                }, 0);
                var id2 = QPTimer.setTimeout(function(){
                }, 0);
                compare(count1, 0);
                compare(count2, 0);
                compare(parseInt(id1), id1);
                compare(parseInt(id2), id2);
                compare(id1 !== id2, true);
                compare(count1, 1);
                compare(count2, 1);
                compare(count1, 1);
                compare(count2, 1);

        function wait(val)
                console.log("wait", val)

        function compare(val1, val2) {

Method Documentation


Clears the timer with the given ID.

The id parameter

The ID of the timer to clear. This ID was set by the setTimeout method.

int setTimeout(func, int interval)

Sets a new timeout, returning a specific ID for the timer. It will evaluate and execute the given function when the specified amount of milliseconds has elapsed.

The func parameter

The function to execute when the timer has completed.

The interval parameter

The amount of time until the timeout property is evaluated. This is counted in milliseconds, i.e. entering 1000 will cause the timer to last for one second.