Package-level declarations

Types

Link copied to clipboard
open class IdleDeadline

The IdleDeadline interface is used as the data type of the input parameter to idle callbacks established by calling Window.requestIdleCallback(). It offers a method, timeRemaining(), which lets you determine how much longer the user agent estimates it will remain idle and a property, didTimeout, which lets you determine if your callback is executing because its timeout duration expired.

Link copied to clipboard
typealias IdleRequestCallback = (deadline: IdleDeadline) -> Unit
Link copied to clipboard
sealed interface IdleRequestId
Link copied to clipboard
Link copied to clipboard
open class Scheduler

The Scheduler interface of the Prioritized Task Scheduling API provides methods for scheduling prioritized tasks.

Link copied to clipboard
typealias SchedulerPostTaskCallback<T> = () -> T
Link copied to clipboard
Link copied to clipboard
open class TaskController(init: TaskControllerInit = definedExternally) : AbortController

The TaskController interface of the Prioritized Task Scheduling API represents a controller object that can be used to both abort and change the priority of one or more prioritized tasks. If there is no need to change task priorities, then AbortController can be used instead.

Link copied to clipboard
Link copied to clipboard
sealed interface TaskPriority
Link copied to clipboard

The TaskPriorityChangeEvent is the interface for the prioritychange event.

Link copied to clipboard
open class TaskSignal : AbortSignal

The TaskSignal interface of the Prioritized Task Scheduling API represents a signal object that allows you to communicate with a prioritized task, and abort it or change the priority (if required) via a TaskController object.

Link copied to clipboard

Functions

Link copied to clipboard
suspend fun awaitIdleCallback(options: IdleRequestOptions? = null): IdleDeadline
Link copied to clipboard

The window.cancelIdleCallback() method cancels a callback previously scheduled with window.requestIdleCallback().

Link copied to clipboard
suspend fun <T : JsAny?> Scheduler.postTask(callback: SchedulerPostTaskCallback<T>): T

The postTask() method of the Scheduler interface is used for adding tasks to be scheduled according to their priority.

Link copied to clipboard
external fun requestIdleCallback(callback: IdleRequestCallback, options: IdleRequestOptions? = definedExternally): IdleRequestId

The window.requestIdleCallback() method queues a function to be called during a browser's idle periods. This enables developers to perform background and low priority work on the main thread, without impacting latency-critical events such as animation and input response. Functions are generally called in first-in-first-out order; however, callbacks which have a timeout specified may be called out-of-order if necessary in order to run them before the timeout elapses.

Link copied to clipboard
inline suspend fun Scheduler.yield()

The yield() method of the Scheduler interface is used for yielding to the main thread during a task and continuing execution later, with the continuation scheduled as a prioritized task (see the Prioritized Task Scheduling API for more information). This allows long-running work to be broken up so the browser stays responsive.