Class: Event

Event

new Event()

A generic utility class for managing subscribers for a particular event. This class is usually instantiated inside of a container class and exposed as a property for others to subscribe to.
Source:
Example
MyObject.prototype.myListener = function(arg1, arg2) {
    this.myArg1Copy = arg1;
    this.myArg2Copy = arg2;
}

var myObjectInstance = new MyObject();
var evt = new Cesium.Event();
evt.addEventListener(MyObject.prototype.myListener, myObjectInstance);
evt.raiseEvent('1', '2');
evt.removeEventListener(MyObject.prototype.myListener);

Members

(readonly) numberOfListeners :Number

The number of listeners currently subscribed to the event.
Type:
  • Number
Source:

Methods

addEventListener(listener, scopeopt) → {Event~RemoveCallback}

Registers a callback function to be executed whenever the event is raised. An optional scope can be provided to serve as the this pointer in which the function will execute.
Parameters:
Name Type Attributes Description
listener function The function to be executed when the event is raised.
scope Object <optional>
An optional object scope to serve as the this pointer in which the listener function will execute.
Source:
See:
Returns:
A function that will remove this event listener when invoked.
Type
Event~RemoveCallback

raiseEvent(arguments)

Raises the event by calling each registered listener with all supplied arguments.
Parameters:
Name Type Description
arguments * This method takes any number of parameters and passes them through to the listener functions.
Source:
See:

removeEventListener(listener, scopeopt) → {Boolean}

Unregisters a previously registered callback.
Parameters:
Name Type Attributes Description
listener function The function to be unregistered.
scope Object <optional>
The scope that was originally passed to addEventListener.
Source:
See:
Returns:
true if the listener was removed; false if the listener and scope are not registered with the event.
Type
Boolean

Type Definitions

RemoveCallback()

A function that removes a listener.
Source: