revite/src/lib/eventEmitter.ts

29 lines
688 B
TypeScript
Raw Normal View History

import EventEmitter from "eventemitter3";
2021-07-05 06:23:23 -04:00
export const InternalEvent = new EventEmitter();
2021-07-05 06:23:23 -04:00
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[]) {
2021-07-05 06:23:23 -04:00
InternalEvent.emit(ns + "/" + event, ...args);
}
// Event structure: namespace/event
/// Event List
// - MessageRenderer/edit_last
// - MessageRenderer/edit_message
// - Intermediate/open_profile
// - Intermediate/navigate
// - MessageBox/append
// - TextArea/focus
2021-06-23 13:26:41 -04:00
// - ReplyBar/add
2021-06-28 05:17:38 -04:00
// - PWA/update