Function createIdlePromise

  • Creates an idle Promise instance that when resolved or rejected will execute it's pending chained operations asynchronously using the requestIdleCallback API (if available) with the optional provided timeout value to schedule when the chained items will be executed. When requestIdleCallback is not available this becomes the same as createAsyncPromise which uses setTimeout to schedule executions.

    Type Parameters

    • T

    Parameters

    • executor: PromiseExecutor<T>

      The function to be executed during the creation of the promise. Any errors thrown in the executor will cause the promise to be rejected. The return value of the executor is always ignored

    • Optionaltimeout: number

      Optional deadline timeout to wait before processing the items, defaults to undefined. 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 IPromise<T>