|
@@ -102,33 +102,30 @@ class StateDB implements IStateDB {
|
|
|
|
|
|
this.namespace = namespace;
|
|
|
|
|
|
- // Retrieve the window name, which is used as a namespace prefix.
|
|
|
- this._ready = (windowName || Promise.resolve('')).then(name => {
|
|
|
- this._window = name;
|
|
|
+ this._window = windowName || '';
|
|
|
+ this._ready = (transform || Promise.resolve(null)).then(transformation => {
|
|
|
|
|
|
- if (!transform) {
|
|
|
+ if (!transformation) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- return transform.then(transformation => {
|
|
|
- const { contents, type } = transformation;
|
|
|
-
|
|
|
- switch (type) {
|
|
|
- case 'cancel':
|
|
|
- return;
|
|
|
- case 'clear':
|
|
|
- this._clear();
|
|
|
- return;
|
|
|
- case 'merge':
|
|
|
- this._merge(contents || { });
|
|
|
- return;
|
|
|
- case 'overwrite':
|
|
|
- this._overwrite(contents || { });
|
|
|
- return;
|
|
|
- default:
|
|
|
- return;
|
|
|
- }
|
|
|
- });
|
|
|
+ const { contents, type } = transformation;
|
|
|
+
|
|
|
+ switch (type) {
|
|
|
+ case 'cancel':
|
|
|
+ return;
|
|
|
+ case 'clear':
|
|
|
+ this._clear();
|
|
|
+ return;
|
|
|
+ case 'merge':
|
|
|
+ this._merge(contents || { });
|
|
|
+ return;
|
|
|
+ case 'overwrite':
|
|
|
+ this._overwrite(contents || { });
|
|
|
+ return;
|
|
|
+ default:
|
|
|
+ return;
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -455,7 +452,7 @@ namespace StateDB {
|
|
|
transform?: Promise<DataTransform>;
|
|
|
|
|
|
/**
|
|
|
- * An optional promise that resolves to a name for the application window.
|
|
|
+ * An optional name for the application window.
|
|
|
*
|
|
|
* #### Notes
|
|
|
* In environments where multiple windows can instantiate a state database,
|
|
@@ -463,7 +460,7 @@ namespace StateDB {
|
|
|
* local storage that is shared by all windows. In JupyterLab, this window
|
|
|
* name is generated by the `IWindowResolver` extension.
|
|
|
*/
|
|
|
- windowName?: Promise<string>;
|
|
|
+ windowName?: string;
|
|
|
}
|
|
|
}
|
|
|
|