本文整理匯總了TypeScript中ts-async-eventemitter.AsyncEventEmitter類的典型用法代碼示例。如果您正苦於以下問題:TypeScript AsyncEventEmitter類的具體用法?TypeScript AsyncEventEmitter怎麽用?TypeScript AsyncEventEmitter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了AsyncEventEmitter類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: return
/**
* The method is used to register event on the event emitter
* and return a function to unsubscribe it.
* @param eventName event to register on
* @param handler handler to call when event triggers
* @returns unsubscribe function to call when done
*/
private _registerEvent<T>(eventName: string, handler: (...args: any[]) => T | Promise<T>): () => void {
this._ee.on(eventName, handler);
return () => {
if ( undefined !== this._ee ) {
this._ee.removeListener(eventName, handler);
}
};
}
示例2: dispose
/**
* The method is used to dispose the collection.
* @returns promise that will resolve once the object can be deleted
*/
public async dispose(): Promise<void> {
await this._ee.emitAsync<void>("dispose");
delete this._db;
this._ee.removeAllListeners();
delete this._ee;
}
示例3:
o.item.promise.then(() => {
isItemResolved = true;
return this._ee.emitAsync<void>("insert", o.item);
});