Extract Event clas to own file

This commit is contained in:
Kevin Sawicki 2016-06-16 09:51:54 -07:00
parent 7f9fa92e2d
commit 3aecb11094
4 changed files with 29 additions and 40 deletions

View file

@ -1,31 +1,9 @@
const {ipcRenderer} = require('electron')
const Event = require('./extensions/event')
const url = require('url')
let nextId = 0
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)
}
}
}
class Tab {
constructor (tabId) {
this.id = tabId