Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listeners incorrectly removed #23

Open
lpinca opened this issue Dec 4, 2017 · 3 comments
Open

Listeners incorrectly removed #23

lpinca opened this issue Dec 4, 2017 · 3 comments

Comments

@lpinca
Copy link
Member

lpinca commented Dec 4, 2017

Ultron removes listeners not added with Ultron when the listener is the same.

const EventEmitter = require('events');
const assert = require('assert');
const Ultron = require('.');

function listener() {}

const ee = new EventEmitter();
const ultron = new Ultron(ee);

ee.on('foo', listener);
ultron.on('foo', listener);

ultron.remove('foo');

assert.strictEqual(ee.listenerCount('foo'), 1);

The issue has been indirectly reported by @apapirovski in nodejs/node#17440 (comment).

@lpinca
Copy link
Member Author

lpinca commented Dec 4, 2017

I think that using Ultron to add an already existing listener on an event emitter or using the event emitter to add a listener already added with Ultron doesn't make much sense so this is probably an edge case, but still valid.

@Horaddrim
Copy link

I think it's valid, I can PR this if you guys think it's cool! 😄

@lpinca
Copy link
Member Author

lpinca commented Apr 20, 2018

Yes, fixing this would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants