refactoring, more possible branch fixes + lint

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman committed 2021-05-08 15:06:27 +03:00
1 parent 0c8ff6a1d6
commit 6ee2385d3c
13 files changed
+61 -70

No files matched your search

+2 -3
View File
@@ -25,7 +25,7 @@ The following example code creates a store for the `appPreferences` guide exampl
``` typescript
import { Store } from "@k8slens/extensions";
import { observable, toJS, makeObservable } from "mobx";
import { observable, makeObservable } from "mobx";
export type ExamplePreferencesModel = {
enabled: boolean;
@@ -51,7 +51,7 @@ export class ExamplePreferencesStore extends Store.ExtensionStore<ExamplePrefere
toJSON(): ExamplePreferencesModel {
return {
enabled: toJS(this.enabled)
enabled: this.enabled
};
}
}
@@ -72,7 +72,6 @@ The `enabled` field of the `ExamplePreferencesStore` is set to the value from th
The `toJSON()` method is complementary to `fromStore()`.
It is called when the store is being saved.
`toJSON()` must provide a JSON serializable object, facilitating its storage in JSON format.
The `toJS()` function from [`mobx`](https://mobx.js.org/README.html) is convenient for this purpose, and is used here.
Finally, `ExamplePreferencesStore` is created by calling `ExamplePreferencesStore.getInstanceOrCreate()`, and exported for use by other parts of the extension.
Note that `ExamplePreferencesStore` is a singleton.