cf2:TimerQueue

Purpose

This component allows applications to perform tasks after a specified period of time. It maintains a list of the cf2:TimerTask components sorted by the order in which they should be called. The timer calls the queue at the time specified by the first task in the queue. When it is called, the queue will remove the first task from the queue and then call it. If the task is a periodic task, then the queue will calculate the next time the task should be called, and will add it into the appropriate place in the queue. Adding and removing tasks may change the first task in the queue and so will cause the timer to be reset.

Exported Features

cf2:TimerQueue

Imported Features

n/a

JavaScript

This component is provided by the V$.TimerQueue object.

every(function,interval)

Adds a function that will be called every interval milliseconds.

Parameter Description Type
function The function to call every interval milliseconds. Function
interval The interval in milliseconds between calls to the function. int
once(function,delay)

Adds a function that will be called once after delay milliseconds.

Parameter Description Type
function The function to call after delay milliseconds. Function
delay The delay in milliseconds. int

Example

The following code can be used to make a looping slide-view change slides every 2 seconds.

V$C.starting(function (c) {
  c.get('slideB1').setLoop(true);
  var timer1 = new V$.cf2.TimerQueue();
  var id1 = timer1.every(function () {
    c.get('slideB1').next()
  },
  2000);
});

Related topics