Wolfy87/EventEmitter — Issue #18: Unable to specify which [listener, scope] combination to remove in removeListener
Author: wemrysi
Created: 2011-11-21 01:11:57+00:00
State: open

The addition of a scope argument to ```addListener``` is convenient, but there isn't a way to specify which [listener, scope] combination to remove when calling ```removeListener```.

```javascript
var ee = new EventEmitter;
var scope1 = {x: 1};
var scope2 = {x: 2};
function f() { console.log(this.x); }
ee.addListener('anEvent', f, scope1);
ee.addListener('anEvent', f, scope2);
ee.removeListener('anEvent', f); // <--- This is not well-defined
```

Currently, the behavior seems to be to remove the ```[f, scope1]``` combination as it was added first, but not remove the ```[f, scope2]``` combination. Calling ```ee.removeListener('anEvent', f)``` twice results in both combinations being removed.

This inconsistency may present issues for other methods that operate over listeners, like ```eachListener``` and ```listeners```.