postTask method
- SchedulerPostTaskCallback callback, [
- SchedulerPostTaskOptions options
The postTask()
method of the Scheduler interface is used for
adding tasks to be
scheduled
according to their
priority.
The method allows users to optionally specify a minimum delay before the task will run, a priority for the task, and a signal that can be used to modify the task priority and/or abort the task. It returns a promise that is resolved with the result of the task callback function, or rejected with the abort reason or an error thrown in the task.
Task priority can be
mutable or immutable.
If the task priority will never need to change then it should be set using
the options.priority
parameter (any priority set through a signal will
then be ignored).
You can still pass an AbortSignal (which has no priority) or
TaskSignal to the options.signal
parameter for aborting the task.
If the task priority might need to be changed the options.priority
parameter must not be set.
Instead a TaskController should be created and its TaskSignal should
be passed to options.signal
.
The task priority will be initialized from the signal priority, and can
later be modified using the signal's associated TaskController.
If no priority is set then the task priority defaults to
"user-visible"
.
If a delay is specified and greater than 0, then the execution of the task will be delayed for at least that many milliseconds. Otherwise the task is immediately scheduled for prioritization.
Implementation
external JSPromise<JSAny?> postTask(
SchedulerPostTaskCallback callback, [
SchedulerPostTaskOptions options,
]);