Namespace: Timers:schedule

Timers:schedule

Source:

Methods

schedule(ms, callback, oldTimeropt, nullable) → {Object}

Setup a timer for one-time execution of a callback, kills old timer if given to prevent overlapping timers.

Parameters:
Name Type Attributes Default Description
ms Number

time in milliseconds until execution

callback function

callback function to execute after ms

oldTimer Object | Number <optional>
<nullable>
null

if set, kills the timer before setting up new one

Source:
See:
Throws:

error if ms is negative or callback is not a function

Returns:
new timer
Type
Object
Example
const timer = schedule(1000, function(){ alert('time for tea'); });
const timer = schedule(2000, function(){ alert('traffic jam, tea has to wait'); }, timer);