2.0.0 - _events is undefined when extending ee3
stbaer opened this issue · comments
Steffen Bär commented
Hi, not sure if this is a bug or if I do something wrong. Before upgrading to 2.0.0 everything worked fine. Am extending a class with eventemitter3 like this:
function MyClass(){...}
MyClass.prototype = Object.create(EventEmitter.prototype);
MyClass.prototype.constructor = MyClass;
MyClass.prototype.someMethod = function(){
this.emit('notify');
}
Now listening to the notify event throws an error:
var mv = new MyClass();
mc.on('notify', handleNotify);
// -> Uncaught TypeError: Cannot read property 'notify' of undefined
// ( _events is undefined in EventEmitter.prototype.on )
Luigi Pinca commented
Yes, you have to invoke the super constructor in your child constructor.
Please read the release notes.
Steffen Bär commented
👍 Thank you, I didn't see the release notes.