new EventHelper
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
var helper = new EventHelper(); helper.add(someObject.event, listener1, this); helper.add(otherObject.event, listener2, this); // later... helper.removeAll();
See:
Source:
Methods
-
add
-
Adds a listener to an event, and records the registration to be cleaned up later.
Parameters:
Name Type Argument Description eventEvent The event to attach to. listenerFunction The function to be executed when the event is raised. scopeObject <optional>
An optional object scope to serve as the thispointer in which the listener function will execute.Throws:
-
DeveloperError : event is required and must be a function.
-
DeveloperError : listener is required and must be a function.
-
-
removeAll
-
Unregisters all previously added listeners.
