Skip to content

Commit

Permalink
fix: mod export issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim-Lin-4549 committed Jan 28, 2025
1 parent 48d3cee commit b937249
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/modules/ModEventBus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ class EventBus {
if (handler) {
// 移除指定的事件处理器
const handlers = this.events.get(event)!;
this.events.set(event, handlers.filter(h => h !== handler));
this.events.set(
event,
handlers.filter((h) => h !== handler)
);
} else {
// 移除所有该事件的处理器
this.events.delete(event);
Expand All @@ -29,11 +32,11 @@ class EventBus {
emit<T = any>(event: string, payload?: T): void {
const handlers = this.events.get(event);
if (handlers) {
handlers.forEach(handler => handler(payload ?? {}));
handlers.forEach((handler) => handler(payload ?? {}));
}
}
}

// 实例化 EventBus
const eventBus = new EventBus();
export default eventBus;
const ModEventBus = new EventBus();
export { ModEventBus };

0 comments on commit b937249

Please sign in to comment.