Releases: primus/eventemitter3
3.1.2
3.1.1
3.1.0
3.0.1
3.0.0
Breaking changes
EventEmitter.prototype.listeners()
always returns an array. UseEventEmitter.prototype.listenerCount()
for existence checking.EventEmitter.prototype.setMaxListeners()
has been removed. It was a noop and documented as not supported.- Bower and Component are no longer supported.
Features
- Added
EventEmitter.prototype.listenerCount()
.
UMD bundle
The npm package now contains a minified UMD bundle.
TypeScript definitions
ES6 import
This release comes with a minor fix that allows EventEmitter
to be imported as module namespace in ES6-compatible environments.
import { EventEmitter } from 'eventemitter3';
Performance improvements
This release comes with some nice optimizations which make 2.0.0
our fastest release ever. If you are curious you can see the results of our benchmarks here: https://github.com/primus/eventemitter3/blob/master/benchmarks/README.md.
Breaking changes
The reason for the major version bump is that there is a small breaking change.
With eventemitter3@<2.0.0
you could inherit from the EventEmitter
class without calling the super constructor.
var EventEmitter = require('eventemitter3');
function MyEmitter() {}
MyEmitter.prototype = Object.create(EventEmitter.prototype, {
constructor: { value: MyEmitter }
});
With [email protected]
this no longer works. Super constructor invocation is required.
var EventEmitter = require('eventemitter3');
function MyEmitter() {
EventEmitter.call(this);
}
MyEmitter.prototype = Object.create(EventEmitter.prototype, {
constructor: { value: MyEmitter }
});
eventNames
This release ships with a new method called eventNames
. It returns an array listing the events for which the emitter has registered listeners. The values in the array will be strings or Symbols.
const EventEmitter = require('eventemitter3');
const ee = new EventEmitter();
ee.on('foo', () => {});
ee.on('bar', () => {});
ee.on(Symbol('s'), () => {});
console.log(ee.eventNames());
// => [ 'foo', 'bar', Symbol(s) ]