# Event

#### new Cesium.Event()
engine/Source/Core/Event.js 24

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.

##### Example:

    MyObject.prototype.myListener = function(arg1, arg2) {
        this.myArg1Copy = arg1;
        this.myArg2Copy = arg2;
    }

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

### Members

#### readonly numberOfListeners : number
engine/Source/Core/Event.js 38

The number of listeners currently subscribed to the event.

### Methods

#### addEventListener(listener, scope) → Event.RemoveCallback
engine/Source/Core/Event.js 58

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.

Name | Type | Description
--- | --- | ---
`listener` | Listener | 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.

##### Returns:

A function that will remove this event listener when invoked.

##### See:

- Event#raiseEvent
- Event#removeEventListener

#### raiseEvent(arguments)
engine/Source/Core/Event.js 128

Raises the event by calling each registered listener with all supplied arguments.

Name | Type | Description
--- | --- | ---
`arguments` | Parameters.<Listener> | repeatable This method takes any number of parameters and passes them through to the listener functions.

##### See:

- Event#addEventListener
- Event#removeEventListener

#### removeEventListener(listener, scope) → boolean
engine/Source/Core/Event.js 82

Unregisters a previously registered callback.

Name | Type | Description
--- | --- | ---
`listener` | Listener | The function to be unregistered.
`scope` | object | optional The scope that was originally passed to addEventListener.

##### Returns:

`true` if the listener was removed; `false` if the listener and scope are not registered with the event.

##### See:

- Event#addEventListener
- Event#raiseEvent

### Type Definitions

#### Cesium.Event.RemoveCallback()
engine/Source/Core/Event.js 159

A function that removes a listener.

Need help? The fastest way to get answers is from the community and team on the Cesium Forum.