EventAPI#

Interface EventAPI

These functions allow adding and removing listeners to be able to react to events on arbitrary nodes.

Example

// Get an instance of the ContextAPI
const myContext : ContextAPI = webvis.getContext( "example" )

// Listen for newly added nodes
myContext.registerListener( [myContext.EventType.NODE_ADDED], (event) => {

// Prints the nodeID of the added node.
console.log(event.targetNodeID);
});

Hierarchy

Methods

  • Registers the listener to the node with the matching nodeID and returns the id of the listener. The observeSubTree flag allows to observe the whole subtree under the respective node with the listener. With the eventTypes array, you can specify the types of events the listener should be reacting on. If an empty array is passed, the listener will react on all event types.

    Type Parameters

    Parameters

    • eventTypes: EventType[]

      The kind of events on which the event listener should listen.

    • listener: IEventListener<T>

      The event listener.

    • Optional nodeID: number

      The id of the node on which the event listener should be registered.

    • Optional observeSubTree: boolean

      Indicates whether the event listener should also listen to events in all child nodes. This has an effect on NODE_* events only.

    Returns number

    The id of the event listener.

  • Removes the listener for the given listenerID.

    Parameters

    • listenerID: number

      The id of the event listener that should be unregistered.

    Returns void


Did you find this page useful? Please give it a rating:
Thank you for rating this page!
Any issues or feedback?
What kind of problem would you like to report?
Please tell us more about what's wrong: