Docs
This commit is contained in:
@@ -66,6 +66,19 @@ export class EventEmitter<T, U = void> implements IEventEmitter<T, U> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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<string>();
|
||||||
|
* // ...
|
||||||
|
* onFoo(e => handle(e));
|
||||||
|
* onFoo.fire('bar');
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
export function initEvent<T, U = void>(): IEventWithEmitter<T, U> {
|
export function initEvent<T, U = void>(): IEventWithEmitter<T, U> {
|
||||||
const emitter = new EventEmitter<T, U>();
|
const emitter = new EventEmitter<T, U>();
|
||||||
const event = emitter.event;
|
const event = emitter.event;
|
||||||
|
|||||||
Reference in New Issue
Block a user