TaskController: TaskController() constructor
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.
TheTaskController() constructor creates a newTaskController object, optionally setting the initialpriority of its associatedsignal.
If no priority is set, the signal priority defaults touser-visible
In this article
Syntax
js
new TaskController()new TaskController(options)Parameters
optionsOptionalAn object with the following properties:
priorityOptionalThepriority of the signal associated with this
TaskController.One of:"user-blocking","user-visible"(default),"background".
Examples
This code shows how to construct a task controller that has a signal with default priority (user-visible).
js
const controller = new TaskController();To construct a task controller that has a specific signal priority, pass thepriority as a property of the optional argument.
js
controller2 = new TaskController({ priority: "user-blocking" });Specifications
| Specification |
|---|
| Prioritized Task Scheduling> # dom-taskcontroller-taskcontroller> |