浏览代码

Wait until service manager is ready.

Afshin Darian 7 年之前
父节点
当前提交
79cde72e5a
共有 1 个文件被更改,包括 5 次插入6 次删除
  1. 5 6
      packages/apputils-extension/src/index.ts

+ 5 - 6
packages/apputils-extension/src/index.ts

@@ -60,8 +60,8 @@ function apiError(id: string, xhr: XMLHttpRequest): Error {
 /**
  * Create a data connector to access plugin settings.
  */
-function newConnector(manager: IServiceManager): IDataConnector<ISettingRegistry.IPlugin, JSONObject> {
-  return {
+function newConnector(manager: IServiceManager): Promise<IDataConnector<ISettingRegistry.IPlugin, JSONObject>> {
+  return manager.ready.then(() => ({
     /**
      * Retrieve a saved bundle from the data connector.
      */
@@ -86,7 +86,7 @@ function newConnector(manager: IServiceManager): IDataConnector<ISettingRegistry
         throw apiError(id, (reason as ServerConnection.IError).xhr);
       });
     }
-  };
+  }));
 }
 
 
@@ -129,9 +129,8 @@ const palettePlugin: JupyterLabPlugin<ICommandPalette> = {
  */
 const settingPlugin: JupyterLabPlugin<ISettingRegistry> = {
   id: 'jupyter.services.setting-registry',
-  activate: (app: JupyterLab, services: IServiceManager) => {
-    return new SettingRegistry({ connector: newConnector(services) });
-  },
+  activate: (app: any, services: IServiceManager) => newConnector(services)
+    .then(connector => new SettingRegistry({ connector })),
   autoStart: true,
   provides: ISettingRegistry,
   requires: [IServiceManager]