當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ts-async-eventemitter.AsyncEventEmitter類代碼示例

本文整理匯總了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);
         }
     };
 }
開發者ID:DxCx,項目名稱:storage_service,代碼行數:15,代碼來源:ReactiveCollection.ts

示例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;
 }
開發者ID:DxCx,項目名稱:storage_service,代碼行數:10,代碼來源:ReactiveCollection.ts

示例3:

 o.item.promise.then(() => {
     isItemResolved = true;
     return this._ee.emitAsync<void>("insert", o.item);
 });
開發者ID:DxCx,項目名稱:storage_service,代碼行數:4,代碼來源:ReactiveCollection.ts


注:本文中的ts-async-eventemitter.AsyncEventEmitter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。