mirror of https://gitee.com/godoos/godoos.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
574 B
19 lines
574 B
import { useSystem } from '../index.ts';
|
|
import { Eventer } from './Eventer';
|
|
|
|
function initEventer() {
|
|
return new Eventer();
|
|
}
|
|
function emitEvent(event: string, data?: any) {
|
|
useSystem().emitEvent(event, data);
|
|
}
|
|
|
|
function mountEvent(event: string | string[], callback: (source: string, data: any) => void): void {
|
|
useSystem().mountEvent(event, callback);
|
|
}
|
|
function redirectEvent(source: string, target: string) {
|
|
mountEvent(source, (_: string, data: unknown) => {
|
|
emitEvent(target, data);
|
|
});
|
|
}
|
|
export { initEventer, emitEvent, mountEvent, redirectEvent };
|
|
|