Skip to main content

on

Registers a callback that will be invoked when an event occurs on the page. Current supported events are:

  • "nodechange": Emitted when a node is added, removed, or updated.

Supported on:

Signature​

on(type: 'nodechange', callback: (event: NodeChangeEvent) => void): void

Parameters​

type​

The type of event to listen for.

callback​

The callback to be invoked when the event occurs.

Remarks​

Available event types​

"nodechange"​

This event will be emitted when a node on the page is added, removed, or updated.

The callback will receive a NodeChangeEvent with the below interface:

interface NodeChangeEvent {
nodeChanges: NodeChange[]
}

There are 3 different NodeChange types. Each of these changes has a type property to distinguish them:

Changetype propertyDescription
CreateChange'CREATE'A node has been created in the page. If a node with nested children is being added to the page a CreateChange will only be made for the highest level parent that was added to the page.
DeleteChange'DELETE'A node has been removed from the page. If a node with nested children is being removed from the page a DeleteChange will only be made for the highest level parent that was removed from the page.
PropertyChange'PROPERTY_CHANGE'A property of a node has changed.