MCPcopy Create free account
hub / github.com/esengine/esengine / emitAsync

Method emitAsync

packages/core/src/ECS/Core/EventBus.ts:63–73  ·  view source on GitHub ↗

* 异步发射事件 * @param eventType 事件类型 * @param data 事件数据 * @param enhance 是否增强事件数据(添加timestamp、eventId等),默认false提升性能

(eventType: string, data: T, enhance: boolean = false)

Source from the content-addressed store, hash-verified

61 * @param enhance 是否增强事件数据(添加timestamp、eventId等),默认false提升性能
62 */
63 public async emitAsync<T>(eventType: string, data: T, enhance: boolean = false): Promise<void> {
64 this.validateEventType(eventType);
65
66 const finalData = enhance ? this.enhanceEventData(eventType, data) : data;
67
68 if (this.isDebugMode) {
69 EventBus._logger.info(`发射异步事件: ${eventType}`, finalData);
70 }
71
72 await this.eventSystem.emit(eventType, finalData);
73 }
74
75 /**
76 * 监听事件

Callers 1

EventBus.test.tsFile · 0.45

Calls 4

validateEventTypeMethod · 0.95
enhanceEventDataMethod · 0.95
infoMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected