# EventHelper

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

A convenience object that simplifies the common pattern of attaching event listeners to several events, then removing all those listeners at once later, for example, in a destroy method.

##### Example:

    const helper = new Cesium.EventHelper();

    helper.add(someObject.event, listener1, this);
    helper.add(otherObject.event, listener2, this);

    // later...
    helper.removeAll();

##### See:

- Event

### Methods

#### add(event, listener, scope) → EventHelper.RemoveCallback
engine/Source/Core/EventHelper.js 39

Adds a listener to an event, and records the registration to be cleaned up later.

Name | Type | Description
--- | --- | ---
`event` | Event | The event to attach to.
`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.

##### Returns:

A function that will remove this event listener when invoked.

##### See:

- Event#addEventListener

#### removeAll()
engine/Source/Core/EventHelper.js 62

Unregisters all previously added listeners.

##### See:

- Event#removeEventListener

### Type Definitions

#### Cesium.EventHelper.RemoveCallback()
engine/Source/Core/EventHelper.js 70

A function that removes a listener.

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