瀏覽代碼

DataChange => DataTransform

Afshin Darian 7 年之前
父節點
當前提交
3467646adf
共有 2 個文件被更改,包括 11 次插入9 次删除
  1. 9 7
      packages/apputils-extension/src/index.ts
  2. 2 2
      packages/coreutils/src/statedb.ts

+ 9 - 7
packages/apputils-extension/src/index.ts

@@ -218,13 +218,15 @@ const state: JupyterLabPlugin<IStateDB> = {
   provides: IStateDB,
   requires: [IRouter],
   activate: (app: JupyterLab, router: IRouter) => {
+    let command: string;
+    let resolved = false;
+
     const { commands, info } = app;
-    const delegate = new PromiseDelegate<StateDB.DataChange>();
+    const transform = new PromiseDelegate<StateDB.DataTransform>();
     const state = new StateDB({
       namespace: info.namespace,
-      load: delegate.promise
+      load: transform.promise
     });
-    let resolved = false;
     const disposables = new DisposableSet();
     const pattern = /^\/workspaces\/(.+)/;
     const unload = () => {
@@ -235,11 +237,11 @@ const state: JupyterLabPlugin<IStateDB> = {
       // leave the database intact.
       if (!resolved) {
         console.log('No workspace requested. Leaving state database intact.');
-        delegate.resolve({ type: 'cancel', contents: null });
+        transform.resolve({ type: 'cancel', contents: null });
       }
     };
 
-    let command = CommandIDs.clearStateDB;
+    command = CommandIDs.clearStateDB;
     commands.addCommand(command, {
       label: 'Clear Application Restore State',
       execute: () => state.clear()
@@ -261,14 +263,14 @@ const state: JupyterLabPlugin<IStateDB> = {
         if (!workspace) {
           console.log('No workspace found. Leaving state database intact.');
           resolved = true;
-          delegate.resolve({ type: 'cancel', contents: null });
+          transform.resolve({ type: 'cancel', contents: null });
           return;
         }
 
         // Fetch the workspace and overwrite the state database.
         console.log('Fetch the workspace:', workspace);
         resolved = true;
-        delegate.resolve({ type: 'merge', contents: { } });
+        transform.resolve({ type: 'merge', contents: { } });
       }
     }));
     disposables.add(router.register({ command, pattern }));

+ 2 - 2
packages/coreutils/src/statedb.ts

@@ -358,7 +358,7 @@ namespace StateDB {
    * A data transformation that can be applied to a state database.
    */
   export
-  type DataChange = {
+  type DataTransform = {
     /*
      * The change operation being applied.
      */
@@ -384,7 +384,7 @@ namespace StateDB {
      * An optional promise that resolves with the contents that should reside
      * in the state database.
      */
-    load?: Promise<DataChange>;
+    load?: Promise<DataTransform>;
   }
 }