An abstract class to implement event system
With npm:
npm install @solaldr/emitter
With yarn:
yarn add @solaldr/emitter
A simple example to create a bus.
import Emitter from "emitter"
class ObjectEventable extends Emitter {
constructor() {
super();
this.list = [];
}
add(item) {
this.list.push(item);
this.emit('add');
}
}
var a = new ObjectEventable();
a.on('add', () => {
console.log('Item added');
})
a.add('Test') // Should output 'Item added' in console
A simple example to create a bus.
import Emitter from "emitter"
class Bus extends Emitter {
constructor() {
super();
}
}
export default new Bus();