Global

Methods

[Dynamic] setIntervalAsync(handler, interval, …args) → {SetIntervalAsyncTimer}

Attempts to execute the given handler at regular intervals, while preventing
multiple concurrent executions. The handler will never be executed concurrently
more than once in any given moment. If the running time of any execution exceeds
the desired interval, the following execution will be scheduled as soon as
possible; ie. immediately after the previous execution concludes.
Parameters:
Name Type Attributes Description
handler function Handler function to be executed in intervals.
May be asynchronous.
interval number Interval in milliseconds. Must be at least 10 ms.
args * <repeatable>
Any number of arguments to pass on to the handler.
Source:
Returns:
A timer object which can be used to stop execution with clearIntervalAsync.
Type
SetIntervalAsyncTimer

[Fixed] setIntervalAsync(handler, interval, …args) → {SetIntervalAsyncTimer}

Executes the given handler at fixed intervals, while preventing
multiple concurrent executions. The handler will never be executed
concurrently more than once in any given moment, providing a fixed
time interval between the end of a given execution and the start of
the following one.
Parameters:
Name Type Attributes Description
handler function Handler function to be executed in intervals.
May be asynchronous.
interval number Interval in milliseconds. Must be at least 10 ms.
args * <repeatable>
Any number of arguments to pass on to the handler.
Source:
Returns:
A timer object which can be used to stop execution with clearIntervalAsync.
Type
SetIntervalAsyncTimer

[Legacy] setIntervalAsync(handler, interval, …args) → {SetIntervalAsyncTimer}

Executes the given handler at fixed intervals; ie. the start time
between consecutive executions is always a fixed amount of time.
If a given execution takes longer than the given time interval to
complete, then the handler will be invoked again without waiting
for the previous one to finish. In this scenario, multiple concurrent
executions can and will ocurr, so this function should only be used
when the given handler is reentrancy-safe.
Parameters:
Name Type Attributes Description
handler function Handler function to be executed in intervals.
May be asynchronous.
interval number Interval in milliseconds. Must be at least 10 ms.
args * <repeatable>
Any number of arguments to pass on to the handler.
Source:
Returns:
A timer object which can be used to stop execution with clearIntervalAsync.
Type
SetIntervalAsyncTimer

clearIntervalAsync(timer) → {Promise}

Stops an execution cycle started by setIntervalAsync.
Any ongoing function executions will run until completion, but all future ones will be cancelled.
Parameters:
Name Type Description
timer SetIntervalAsyncTimer
Source:
Returns:
A promise which resolves when all pending executions have finished.
Type
Promise