You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[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.
The text was updated successfully, but these errors were encountered:
mscdex
added
events
Issues and PRs related to the events subsystem / EventEmitter.
question
Issues that look for answers.
labels
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.
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. :)
[This particular method,
EventEmitter.init
(https://github.com/nodejs/node/blob/master/lib/events.js#L42-L58) is effectively the constructor method forEventEmitter
(up to and including requiringthis
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. nothis
) or just removed altogether, since it's really redundant, and I've never seen it used elsewhere in practice.The text was updated successfully, but these errors were encountered: