فهرست منبع

Add `started` promise to JupyterLab class.

Afshin Darian 8 سال پیش
والد
کامیت
9c9c716b81
1فایلهای تغییر یافته به همراه25 افزوده شده و 0 حذف شده
  1. 25 0
      src/application/index.ts

+ 25 - 0
src/application/index.ts

@@ -22,10 +22,35 @@ 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;
+  }
+
+  /**
+   * Start the JupyterLab application.
+   */
+  start(options: Application.IStartOptions = {}): Promise<void> {
+    return super.start(options).then(() => { this._startedResolve(); });
+  }
+
   /**
    * Create the application shell for the JupyterLab application.
    */
   protected createShell(): ApplicationShell {
     return new ApplicationShell();
   }
+
+  private _startedResolve: () => void;
+  private _startedPromise: Promise<void> = null;
 }