2021-06-22 05:28:13 -04:00
|
|
|
import EventEmitter from "eventemitter3";
|
2021-07-05 06:23:23 -04:00
|
|
|
|
2021-06-22 05:28:13 -04:00
|
|
|
export const InternalEvent = new EventEmitter();
|
|
|
|
|
2021-07-05 06:23:23 -04:00
|
|
|
export function internalSubscribe(
|
2021-07-05 06:25:20 -04:00
|
|
|
ns: string,
|
|
|
|
event: string,
|
|
|
|
fn: (...args: any[]) => void,
|
2021-07-05 06:23:23 -04:00
|
|
|
) {
|
2021-07-10 10:57:29 -04:00
|
|
|
InternalEvent.addListener(`${ns}/${event}`, fn);
|
|
|
|
return () => InternalEvent.removeListener(`${ns}/${event}`, fn);
|
2021-06-22 05:28:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export function internalEmit(ns: string, event: string, ...args: any[]) {
|
2021-07-10 10:57:29 -04:00
|
|
|
InternalEvent.emit(`${ns}/${event}`, ...args);
|
2021-06-22 05:28:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Event structure: namespace/event
|
|
|
|
|
|
|
|
/// Event List
|
2021-07-06 18:03:29 -04:00
|
|
|
// - MessageArea/jump_to_bottom
|
2021-06-22 05:28:13 -04:00
|
|
|
// - MessageRenderer/edit_last
|
|
|
|
// - MessageRenderer/edit_message
|
2021-06-22 06:56:37 -04:00
|
|
|
// - Intermediate/open_profile
|
|
|
|
// - Intermediate/navigate
|
|
|
|
// - MessageBox/append
|
|
|
|
// - TextArea/focus
|
2021-06-23 13:26:41 -04:00
|
|
|
// - ReplyBar/add
|
2021-07-07 17:02:18 -04:00
|
|
|
// - Modal/close
|
2021-06-28 05:17:38 -04:00
|
|
|
// - PWA/update
|