Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

EventEmitter docs should indicate that the emitter must be instantiated via util.inherits() and EventEmitter.call(this) #7646

Closed
yunong opened this issue May 19, 2014 · 7 comments

Comments

@yunong
Copy link
Member

yunong commented May 19, 2014

The current EventEmitter docs: http://nodejs.org/api/events.html do not indicate how one should instantiate an instance of the emitter.

The blessed procedure is:

tj.fontaine@joyent.com
11:53 you should util.inherits and EventEmitter.call(this)
@yunong yunong self-assigned this May 19, 2014
@dougwilson
Copy link
Member

Right now it is only semi-documented on https://github.com/joyent/node/wiki/Api-changes-between-v0.8-and-v0.10

@bnoordhuis
Copy link
Member

Semi-blessed, perhaps. MyClass.prototype = new EventEmitter or MyClass.prototype = Object.create(EventEmitter.prototype) are supposed to work as well but that's broken in v0.10, see #7157. Fortunately, it's fixed in master, see #7405.

@vkurchatkin
Copy link

@bnoordhuis MyClass.prototype = Object.create(EventEmitter.prototype) should be ok

@yunong using inherits is not mandatory, any correct javascript inheritance pattern will work

@brendanashworth
Copy link

This was fixed in nodejs/node#2168 - and because I don't think the doc change will be backported, I'll close this issue for now.

@targos
Copy link
Member

targos commented Sep 29, 2015

@brendanashworth even if an issue is still relevant or a fix has to be backported to 0.12 or 0.10, it would be done in nodejs/node.

@brendanashworth
Copy link

@targos hmm.. is there any reason to leave any of these issues open then? :)

@targos
Copy link
Member

targos commented Sep 29, 2015

The only reason I see is for you are doing right now: answering to them, closing and redirecting to nodejs/node if applicable.

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

No branches or pull requests

7 participants