瀏覽代碼

Use PromiseDelegate.

Afshin Darian 8 年之前
父節點
當前提交
5703169f56
共有 1 個文件被更改,包括 9 次插入12 次删除
  1. 9 12
      src/application/index.ts

+ 9 - 12
src/application/index.ts

@@ -1,6 +1,10 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
+import {
+  utils
+} from '@jupyterlab/services';
+
 import {
   Application
 } from 'phosphor/lib/ui/application';
@@ -22,19 +26,11 @@ type JupyterLabPlugin<T> = Application.IPlugin<JupyterLab, T>;
  */
 export
 class JupyterLab extends Application<ApplicationShell> {
-  /**
-   * Create a new JupyterLab instance.
-   */
-  constructor() {
-    super();
-    this._startedPromise = new Promise(fn => { this._startedResolve = fn; });
-  }
-
   /**
    * A promise that resolves when the JupyterLab application is started.
    */
   get started(): Promise<void> {
-    return this._startedPromise;
+    return this._startedDelegate.promise;
   }
 
   /**
@@ -45,7 +41,9 @@ class JupyterLab extends Application<ApplicationShell> {
       return Promise.resolve(void 0);
     }
     this._startedFlag = true;
-    return super.start(options).then(() => { this._startedResolve(); });
+    return super.start(options).then(() => {
+      this._startedDelegate.resolve(void 0);
+    });
   }
 
   /**
@@ -55,7 +53,6 @@ class JupyterLab extends Application<ApplicationShell> {
     return new ApplicationShell();
   }
 
+  private _startedDelegate = new utils.PromiseDelegate<void>();
   private _startedFlag = false;
-  private _startedPromise: Promise<void> = null;
-  private _startedResolve: () => void = null;
 }