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

EventEmitter.removeListener

Wolfy87 edited this page Nov 23, 2011 · 2 revisions

About

Removes a listener for the specified event.

Arguments

EventEmitter.removeListener(type, listener, scope);

  • String type Event type name the listener must have for the event to be removed
  • Function listener Listener the event must have to be removed
  • Object scope The scope the event must have to be removed

Returns

Object The current EventEmitter instance to allow chaining

Notes

The passed listener must be a reference to the original function, you can not use a anonymous function and copy the code. It doesn't work like that.

Examples

var ee = new EventEmitter();

function myListener() {
    console.log('bar');
}

ee.on('foo', myListener);
ee.removeListener('foo', myListener);

You can also add listeners which when fired will call your function with a specified scope.

ee.on('foo', myListener, myScope);
ee.removeListener('foo', myListener, myScope);