up.util up.util.timer(millis, callback)
JavaScript function

Waits for the given number of milliseconds, then runs the given callback.

This function works like the built-in setTimeout(), except that the argument order is flipped for ergonomic reasons.

Instead of up.util.timer(0, fn) you can also use up.util.task(fn).

Example

up.util.timer(3000, function() {
  console.log("Look, it's 3 seconds later!")
})

Parameters

millis
required

The time interval to wait in milliseconds.

Type: number
callback
required

The function to call after waiting.

Type: Function()

Return value

The ID of the scheduled timeout.

To unschedule the task, pass this ID to clearTimeout().

Type: number