Use actions/events for plugin interoperability. Move base case and mute functionality to their own plugins.

This commit is contained in:
Dragory 2018-11-25 17:04:26 +02:00
parent 22c515be38
commit 2e30a3b9e7
14 changed files with 674 additions and 332 deletions

View file

@ -28,11 +28,14 @@ export class QueuedEventEmitter {
listeners.splice(listeners.indexOf(listener), 1);
}
emit(eventName: string, args: any[] = []) {
emit(eventName: string, args: any[] = []): Promise<void> {
const listeners = [...(this.listeners.get(eventName) || []), ...(this.listeners.get("*") || [])];
let promise: Promise<any> = Promise.resolve();
listeners.forEach(listener => {
this.queue.add(listener.bind(null, ...args));
promise = this.queue.add(listener.bind(null, ...args));
});
return promise;
}
}