new CalculateOnIdle()
Manages a queue of low-priority calculations to be completed when processing on the main thread is idle.
This class uses the requestIdleCallback() method to process pending
calculations.
Members
-
:object
calculationCurrent <static>
-
The current calculation metadata.
Type
- object
-
:Array.<object>
calculationsPending <static>
-
A list of pending calculation metadata.
Type
- Array.<object>
-
:boolean
isCalculating <static>
-
Whether or not one or more calculations are pending or in progress.
Type
- boolean
Methods
-
addCalculation(callback, payload [, options]) <static>
-
Add a calculation to the active calculations queue.
Parameters:
Name Type Argument Description callbackfunction A function to invoke in the form
callback(payload, fraction).payloadobject An object to use as the first argument to the callback function.
optionsobject <optional>
An optional configuration object.
Properties of
options:Name Type Argument Description cancelledfunction <optional>
An optional callback function when cancelled, defaults to null.
completefunction <optional>
An optional callback function when complete, defaults to null.
-
calculate() <static>
-
The callback method that handles active executing calculations.
-
cancel() <static>
-
Call this method to cancel all calculations that are currently in progress.
After this method has been called, all currently active calculations will prematurely terminate and be considered completed.