Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

EventEmitter.listeners

Wolfy87 edited this page Nov 5, 2011 · 2 revisions

About

Retrieves and returns the array of listeners for a specified event. Will return an empty array if no listeners where found.

Arguments

EventEmitter.listeners(type);

  • String type Event type name to return all listeners from

Returns

Array Will return either an array of listeners or an empty array if there are none

Examples

var ee = new EventEmitter();
ee.on('foo', function() {
    console.log('bar');
});
var listeners = ee.listeners('foo');

if(listeners) {
    // Do stuff with the listeners
}
else {
    // Show an error or do something else because there are no listeners
}