Revert "Make BaseStore abstract (#1431)"

This reverts commit 4b56ab7c61.
This commit is contained in:
Alex Andreev committed 2020-11-20 07:51:43 +03:00
1 parent a975e3d456
commit 382687775b
3 files changed
+23 -27

No files matched your search

+12 -18
View File
@@ -15,10 +15,7 @@ export interface BaseStoreParams<T = any> extends ConfOptions<T> {
syncOptions?: IReactionOptions;
}
/**
* Note: T should only contain base JSON serializable types.
*/
export abstract class BaseStore<T = any> extends Singleton {
export class BaseStore<T = any> extends Singleton {
protected storeConfig: Config<T>;
protected syncDisposers: Function[] = [];
@@ -149,19 +146,16 @@ export abstract class BaseStore<T = any> extends Singleton {
}
}
/**
* fromStore is called internally when a child class syncs with the file
* system.
* @param data the parsed information read from the stored JSON file
*/
protected abstract fromStore(data: T): void;
@action
protected fromStore(data: T) {
if (!data) return;
this.data = data;
}
/**
* toJSON is called when syncing the store to the filesystem. It should
* produce a JSON serializable object representaion of the current state.
*
* It is recommended that a round trip is valid. Namely, calling
* `this.fromStore(this.toJSON())` shouldn't change the state.
*/
abstract toJSON(): T;
// todo: use "serializr" ?
toJSON(): T {
return toJS(this.data, {
recurseEverything: true,
})
}
}
+3 -3
View File
@@ -2,17 +2,17 @@ import { BaseStore } from "../common/base-store"
import * as path from "path"
import { LensExtension } from "./lens-extension"
export abstract class ExtensionStore<T> extends BaseStore<T> {
export class ExtensionStore<T = any> extends BaseStore<T> {
protected extension: LensExtension
async loadExtension(extension: LensExtension) {
this.extension = extension
return super.load()
await super.load()
}
async load() {
if (!this.extension) { return }
return super.load()
await super.load()
}
protected cwd() {