diff --git a/src/common/EventEmitter.ts b/src/common/EventEmitter.ts index c0074bba..979a6464 100644 --- a/src/common/EventEmitter.ts +++ b/src/common/EventEmitter.ts @@ -66,6 +66,19 @@ export class EventEmitter implements IEventEmitter { } } +/** + * Creates an object that implements both the {@link IEvent} and {@link IEmitter} interfaces. This + * allows more concise instantiation. The idea is to internally use the combined + * {@link IEventWithEmitter} interface and only expose {@link IEvent} externally. + * + * @example + * ```ts + * public readonly onFoo = initEvent(); + * // ... + * onFoo(e => handle(e)); + * onFoo.fire('bar'); + * ``` + */ export function initEvent(): IEventWithEmitter { const emitter = new EventEmitter(); const event = emitter.event;