Type Alias RequestIdleCallback

RequestIdleCallback: ((callback: IdleRequestCallback, options?: IdleRequestOptions) => number)

Type that represents the global requestIdleCallback function, which can be used to schedule work when there is free time in the event loop. Defined as a type alias for easier reference and to support older TypeScript versions.

Type declaration

    • (callback, options?): number
    • Parameters

      • callback: IdleRequestCallback

        A callback function that should be called in the near future, when the event loop is idle. The callback function is passed an IdleDeadline object describing the amount of time available and whether or not the callback has been run because the timeout period expired.

      • Optionaloptions: IdleRequestOptions

        Contains optional configuration parameters. Currently only one property is defined:

        • timeout If the number of milliseconds represented by this parameter has elapsed and the callback has not already been called, then a task to execute the callback is queued in the event loop (even if doing so risks causing a negative performance impact). timeout must be a positive value or it is ignored.

      Returns number

      A handle which can be used to cancel the callback by passing it into the cancelIdleCallback() method.

0.11.2