[name]

JavaScript events for custom objects.
[link:https://github.com/mrdoob/eventdispatcher.js Eventdispatcher on GitHub]

Example

// Adding events to a custom object var Car = function() { this.start = function() { this.dispatchEvent({ type: 'start', message: 'vroom vroom!' }); }; }; // Mixin the EventDispatcher.prototype with the custom object prototype Object.assign(Car.prototype, EventDispatcher.prototype); // Using events with the custom object var car = new Car(); car.addEventListener('start', function(event) { alert(event.message); }); car.start();

Constructor

[name]()

Creates EventDispatcher object.

Methods

[method:null addEventListener]([page:String type], [page:Function listener])

type - The type of event to listen to.
listener - The function that gets called when the event is fired.
Adds a listener to an event type.

[method:Boolean hasEventListener]([page:String type], [page:Function listener])

type - The type of event to listen to.
listener - The function that gets called when the event is fired.
Checks if listener is added to an event type.

[method:null removeEventListener]([page:String type], [page:Function listener])

type - The type of the listener that gets removed.
listener - The listener function that gets removed.
Removes a listener from an event type.

[method:null dispatchEvent]([page:object event])

event - The event that gets fired.
Fire an event type.
[sourceHint]