浏览代码

Delay a document widget from being ready until the context is ready.

Jason Grout 7 年之前
父节点
当前提交
12dfc8e07d
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      packages/docregistry/src/default.ts

+ 4 - 2
packages/docregistry/src/default.ts

@@ -417,15 +417,17 @@ abstract class ABCWidgetFactory<T extends IDocumentWidget, U extends DocumentReg
 export
 class DocumentWidget<T extends Widget = Widget, U extends DocumentRegistry.IModel = DocumentRegistry.IModel> extends MainAreaWidget<T> implements IDocumentWidget<T, U> {
   constructor(options: DocumentWidget.IOptions<T, U>) {
+
+    // Include the context ready promise in the widget ready promise
+    options.ready = Promise.all([options.ready, options.context.ready]).then( () => { return; });
     super(options);
+
     this.context = options.context;
 
     this.context.pathChanged.connect(this._onPathChanged, this);
     this._onPathChanged();
   }
 
-  // TODO: redefine the populated/isPopulated to *also* wait for the context load/rendering
-
   /**
    * Handle a path change.
    */