2018-09-02 16:09:49 +00:00
|
|
|
import * as plugins from './smartevent.plugins';
|
|
|
|
import { EventEmitter } from 'events';
|
2017-04-29 19:23:26 +00:00
|
|
|
|
2018-09-02 16:09:49 +00:00
|
|
|
export { EventEmitter };
|
2017-04-29 19:23:26 +00:00
|
|
|
|
|
|
|
export let once = async <T>(eventEmitter: EventEmitter, eventName: string): Promise<T> => {
|
2018-09-02 16:09:49 +00:00
|
|
|
let done = plugins.smartpromise.defer<T>();
|
|
|
|
eventEmitter.once(eventName, done.resolve);
|
|
|
|
return await done.promise;
|
|
|
|
};
|