@aeres-games/event-emitter
v1.1.0
Published
An Event Emitter used by Aeres Games libraries
Downloads
8
Readme
Aeres Games Event Emitter
A simple event emitter abstract class
Installing
npm require @aeres-games/event-emitter
Usage
Declare a class as an event emitter :
const {EventEmitter} = require('@aeres-games/event-emitter');
class Foo extends EventEmitter
{
//...
}
Then use methods 'on' and 'emit' :
let bar = new Foo();
bar.on('event-name', function(data, time)
{
console.log(this); //bar
});
bar.emit('event-name');
bar.emit('event-name', /* data */{opt1: "test", opt2: true}, /* stack */false, /* time */ new Date());
Use stack = false to disable event caching when no listener is registered.
License
This package is licensed under the MIT license.
Please see the LICENSE file for more informations.