Module: events

This module provides functionality for constructing events similar to WebExtensions events.Event objects.

Source:

Classes

Event

Methods

(static) createEvent(optionsopt) → {Event}

Create a new Event object that implements WebExtensions event syntax, with the provided options.

Parameters:
Name Type Attributes Description
options Object <optional>

The options for the event.

Properties
Name Type Attributes Default Description
name string

The name of the event.

addListenerCallback addListenerCallback <optional>

A function that is called when a listener is added.

removeListenerCallback removeListenerCallback <optional>

A function that is called when a listener is removed.

notifyListenersCallback notifyListenersCallback <optional>

A function that is called before a listener is notified and can filter the notification.

singleton boolean <optional>
false

Whether to allow only one listener for the event.

Source:
Returns:
  • The created Event object.
Type
Event

Type Definitions

addListenerCallback(listener, options)

A callback function that is called immediately before a listener is added.

Parameters:
Name Type Description
listener function

The listener that is being added.

options Object

The options for the listener.

Source:

notifyListenersCallback(listener, listenerArguments, options) → {boolean}

A callback function that is called when a listener may be notified via notifyListeners().

Parameters:
Name Type Description
listener function

The listener that may be called.

listenerArguments Array

The arguments that would be passed to the listener function.

options Options

The options that the listener was added with.

Source:
Returns:

Whether to call the listener.

Type
boolean

removeListenerCallback(listener, options)

A callback function that is called immediately after a listener is removed.

Parameters:
Name Type Description
listener function

The listener that was removed.

options Object

The options that the listener was added with.

Source: