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)
.
up.util.timer(3000, function() {
console.log("Look, it's 3 seconds later!")
})
The time interval to wait in milliseconds.
The function to call after waiting.
The ID of the scheduled timeout.
To unschedule the task, pass this ID to clearTimeout()
.