Timers
The timer module exposes a global API for scheduling functions to be called at some future period of time.
Because the timer functions are globals, there is no need to call require('timers') to use the API.
The timer functions within Node.js implement a similar API as the timers API provided by Web Browsers but use a different internal implementation that is built around the Node.js Event Loop.
Static Members
setImmediate(callback: haxe.Function, args: haxe.extern.Rest): ImmediateSchedules the "immediate" execution of the callback after I/O events' callbacks.
When multiple calls to setImmediate() are made, the callback functions are queued for execution
in the order in which they are created. The entire callback queue is processed every event loop iteration.
If an immediate timer is queued from inside an executing callback, that timer will not be triggered until
the next event loop iteration.
If callback is not a function, a TypeError will be thrown.
This method has a custom variant for promises that is available using util.promisify().
| Name | Type |
|---|---|
callback |
haxe.Function |
args |
haxe.extern.Rest |
| Returns |
|---|
| Immediate |
setInterval(callback: haxe.Function, delay: Int, args: haxe.extern.Rest): TimeoutSchedules repeated execution of callback every delay milliseconds.
When delay is larger than 2147483647 or less than 1, the delay will be set to 1.
Non-integer delays are truncated to an integer.
If callback is not a function, a TypeError will be thrown.
This method has a custom variant for promises that is available using util.promisify().
| Name | Type |
|---|---|
callback |
haxe.Function |
delay |
Int |
args |
haxe.extern.Rest |
| Returns |
|---|
| Timeout |
setTimeout(callback: haxe.Function, delay: Int, args: haxe.extern.Rest): TimeoutSchedules execution of a one-time callback after delay milliseconds.
The callback will likely not be invoked in precisely delay milliseconds.
Node.js makes no guarantees about the exact timing of when callbacks will fire, nor of their ordering.
The callback will be called as close as possible to the time specified.
When delay is larger than 2147483647 or less than 1, the delay will be set to 1.
Non-integer delays are truncated to an integer.
If callback is not a function, a TypeError will be thrown.
This method has a custom variant for promises that is available using util.promisify().
| Name | Type |
|---|---|
callback |
haxe.Function |
delay |
Int |
args |
haxe.extern.Rest |
| Returns |
|---|
| Timeout |
Cancels an Immediate object created by setImmediate().
| Name | Type |
|---|---|
immediate |
Immediate |
Cancels a Timeout object created by setInterval().
| Name | Type |
|---|---|
timeout |
Timeout |
Cancels a Timeout object created by setTimeout().
| Name | Type |
|---|---|
timeout |
Timeout |
Metadata
| Name | Parameters |
|---|---|
:jsRequire |
"timers" |