Back to Content

TaskPriorityChangeEvent

files/en-us/web/api/taskprioritychangeevent/index.md

latest1.8 KB
Original Source

{{APIRef("Prioritized Task Scheduling API")}}{{AvailableInWorkers}}

The TaskPriorityChangeEvent is the interface for the prioritychange event.

{{InheritanceDiagram}}

Constructor

  • {{domxref("TaskPriorityChangeEvent.TaskPriorityChangeEvent", "TaskPriorityChangeEvent()")}}
    • : Creates a new TaskPriorityChangeEvent object, setting an event name and previous priority.

Instance properties

This interface also inherits the properties of its parent, {{domxref("Event")}}.

  • {{domxref("TaskPriorityChangeEvent.previousPriority")}} {{ReadOnlyInline}}

Instance methods

This interface has no methods of its own, but inherits the methods of its parent, {{domxref("Event")}}.

Examples

An object of this type is returned in the handler for a prioritychange event. The code below shows a handler in which the newPriority and previousPriority are logged.

js
// Listen for 'prioritychange' events on the controller's signal.
controller.signal.addEventListener("prioritychange", (event) => {
  const previousPriority = event.previousPriority;
  const newPriority = event.target.priority;
  console.log(`Priority changed from ${previousPriority} to ${newPriority}.`);
});

A more complete live example can be found in prioritychange event > Examples.

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also