electron/lib/renderer/extensions/event.ts
Shelley Vohr ffb53405fb
chore: convert extension apis to TypeScript (#18688)
Converts extensions-related files to TS
2019-06-14 07:52:24 -07:00

20 lines
406 B
TypeScript

export class Event {
private listeners: Function[] = []
addListener (callback: Function) {
this.listeners.push(callback)
}
removeListener (callback: Function) {
const index = this.listeners.indexOf(callback)
if (index !== -1) {
this.listeners.splice(index, 1)
}
}
emit (...args: any[]) {
for (const listener of this.listeners) {
listener(...args)
}
}
}