Edit this page

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 number

The time interval to wait in milliseconds.

callback Function()

The function to call after waiting.

Return value

number

The ID of the scheduled timeout.

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