mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-03 13:38:00 +00:00
Optimize the project structure and introduce DDD design (#394)
This commit is contained in:
18
projects/app/src/web/common/utils/eventbus.ts
Normal file
18
projects/app/src/web/common/utils/eventbus.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export enum EventNameEnum {
|
||||
guideClick = 'guideClick'
|
||||
}
|
||||
type EventNameType = `${EventNameEnum}`;
|
||||
|
||||
export const eventBus = {
|
||||
list: new Map<EventNameType, Function>(),
|
||||
on: function (name: EventNameType, fn: Function) {
|
||||
this.list.set(name, fn);
|
||||
},
|
||||
emit: function (name: EventNameType, data: Record<string, any> = {}) {
|
||||
const fn = this.list.get(name);
|
||||
fn && fn(data);
|
||||
},
|
||||
off: function (name: EventNameType) {
|
||||
this.list.delete(name);
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user