event-kit: add emitAsync.

This commit is contained in:
GlenCFL
2017-10-26 12:10:40 -04:00
parent 92cb1815e6
commit 82bd0f70d8
2 changed files with 12 additions and 0 deletions

View File

@@ -81,3 +81,8 @@ subscription = emitter.preempt("test-event", value => {});
// Event Emission
emitter.emit("test-event");
emitter.emit("test-event", 42);
async function testEmitAsync() {
await emitter.emitAsync("test-event");
await emitter.emitAsync("test-event", 42);
}

View File

@@ -104,4 +104,11 @@ export class Emitter implements DisposableLike {
/** Invoke the handlers registered via ::on for the given event name. */
// tslint:disable-next-line:no-any
emit(eventName: string, value?: any): void;
/**
* Asynchronously invoke the handlers registered via ::on for the given event name.
* @return A promise that will be fulfilled once all handlers have been invoked.
*/
// tslint:disable-next-line:no-any
emitAsync(eventName: string, value?: any): Promise<void>;
}