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

What's the point of keeping EventEmitter.init? #10680

Closed
dead-claudia opened this issue Jan 7, 2017 · 3 comments
Closed

What's the point of keeping EventEmitter.init? #10680

dead-claudia opened this issue Jan 7, 2017 · 3 comments
Labels
events Issues and PRs related to the events subsystem / EventEmitter. question Issues that look for answers.

Comments

@dead-claudia
Copy link

[This particular method, EventEmitter.init(https://github.com/nodejs/node/blob/master/lib/events.js#L42-L58) is effectively the constructor method for EventEmitter (up to and including requiring this to be an event emitter itself), and is completely undocumented. I personally don't see much of a use case for keeping it a separate thing outside parasitically inheriting when you're already extending a non-emitter class (not common). I'm thinking it could either be moved into a static function (i.e. no this) or just removed altogether, since it's really redundant, and I've never seen it used elsewhere in practice.

@mscdex mscdex added events Issues and PRs related to the events subsystem / EventEmitter. question Issues that look for answers. labels Jan 7, 2017
@mscdex
Copy link
Contributor

mscdex commented Jan 7, 2017

By git bisecting you can see when/why the change was made. In this particular case, it was added in 54da818, with the original PR being nodejs/node-v0.x-archive#6693.

The simple answer is that it was added to allow monkey-patching of the EventEmitter constructor, because at least at that time there were (and there may still be) people taking advantage of that ability.

@benjamingr
Copy link
Member

I'm -1 on removing it, breaking compatibility (even with things that are undocumented!) should be done when/if there is a clear benefit in doing so.

While it's not great to have undocumented methods it's practically free to keep around and it does not risk breaking code in the wild.

@addaleax
Copy link
Member

I think the original question here has been answered, so I’m closing this. If there’s need for more discussion, or if you have any follow-up questions, feel free to ask. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
events Issues and PRs related to the events subsystem / EventEmitter. question Issues that look for answers.
Projects
None yet
Development

No branches or pull requests

4 participants