ffb53405fb
Converts extensions-related files to TS
20 lines
406 B
TypeScript
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)
|
|
}
|
|
}
|
|
}
|