TaskSignal
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Note: This feature is available inWeb Workers.
TheTaskSignal interface of thePrioritized Task Scheduling API represents a signal object that allows you to communicate with a prioritized task, and abort it or change thepriority (if required) via aTaskController object.
An object of this type is created, and associated with, aTaskController.The initial priority of the signal may be set by specifying it as an argument to theTaskController() constructor (by default it is"user-visible").The priority can be changed by callingTaskController.setPriority() on the controller.
The signal may be passed as theoptions.signal argument inScheduler.postTask(), after which its associated controller can be used to abort the task.If thetask priority is mutable, the controller can also be used to change the task's priority.Abortable tasks that do not need the priority to change may instead specify anAbortSignal as theoptions.signal argument.
In this article
Instance properties
TheTaskSignal interface also inherits properties from its parent interface,AbortSignal.
TaskSignal.priorityRead onlyReturns the priority of the signal.
Static methods
TheTaskSignal interface inherits methods from its parent interface,AbortSignal.
TaskSignal.any()Returns a
TaskSignalthat aborts when any of the given abort signals abort.
Instance methods
TheTaskSignal interface inherits methods from its parent interface,AbortSignal.
Events
Listen to these events usingaddEventListener() or by assigning an event listener to theoneventname property of this interface.
prioritychangeFired when the priority is changed.This is triggered by calling
TaskController.setPriority()on the associated controller.
Examples
Examples for how theTaskSignal is created and used for prioritizing and aborting tasks can be found here:
Specifications
| Specification |
|---|
| Prioritized Task Scheduling> # tasksignal> |