A javascript library of async functions
Delays the calling of a callback for a given amount of time.
Returns: number
- An id that can be used to clear the callback before it gets called.
Param | Type | Default | Description |
---|---|---|---|
callback | function |
The function to delay execution of. | |
[duration] | number |
0 |
Time in milliseconds. |
Example
import { delay } from 'async-agent';
delay(() => {
console.log('2');
}, 1000);
console.log('1');
// => 1
// (after 1000ms) => 2