Add global event pipeline.

Add message editor back.
This commit is contained in:
Paul
2021-06-22 10:28:13 +01:00
parent ef2848ee25
commit 5db0854b42
5 changed files with 121 additions and 20 deletions

18
src/lib/eventEmitter.ts Normal file
View File

@@ -0,0 +1,18 @@
import EventEmitter from "eventemitter3";
export const InternalEvent = new EventEmitter();
export function internalSubscribe(ns: string, event: string, fn: (...args: any[]) => void) {
InternalEvent.addListener(ns + '/' + event, fn);
return () => InternalEvent.removeListener(ns + '/' + event, fn);
}
export function internalEmit(ns: string, event: string, ...args: any[]) {
InternalEvent.emit(ns + '/' + event, ...args);
}
// Event structure: namespace/event
/// Event List
// - MessageRenderer/edit_last
// - MessageRenderer/edit_message
// - MessageBox/focus