electron/lib/renderer/extensions/event.js
2016-06-16 09:51:54 -07:00

24 lines
406 B
JavaScript

class Event {
constructor () {
this.listeners = []
}
addListener (callback) {
this.listeners.push(callback)
}
removeListener (callback) {
const index = this.listeners.indexOf(callback)
if (index !== -1) {
this.listeners.splice(index, 1)
}
}
emit (...args) {
for (const listener of this.listeners) {
listener(...args)
}
}
}
module.exports = Event