TaskPriorityChangeEvent

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The TaskPriorityChangeEvent is the interface for the prioritychange event.

Event TaskPriorityChangeEvent

Constructor

TaskPriorityChangeEvent()

Creates a new TaskPriorityChangeEvent object, setting an event name and previous priority.

Properties

This interface also inherits the properties of its parent, Event.

TaskPriorityChangeEvent.previousPriority Read only

Returns the priority of the corresponding TaskSignal before this prioritychange event.

Methods

This interface has no methods of its own, but inherits the methods of its parent, 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.

  // 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

Specification
Prioritized Task Scheduling
# sec-task-priority-change-event

Browser compatibility

BCD tables only load in the browser

See also