diff --git a/docs/extensions/guides/stores.md b/docs/extensions/guides/stores.md index c1e0f79770..575cf885da 100644 --- a/docs/extensions/guides/stores.md +++ b/docs/extensions/guides/stores.md @@ -5,13 +5,6 @@ A few of these are exposed by the extensions api for use by the extension develo The `ClusterStore` manages cluster state data such as cluster details, and which cluster is active. The `WorkspaceStore` similarly manages workspace state data, such as workspace name, and which clusters belong to a given workspace. The `ExtensionStore` is a store for managing custom extension state data. -## ClusterStore - -tbd - -## WorkspaceStore - -tbd ## ExtensionStore @@ -62,6 +55,8 @@ export const examplePreferencesStore = ExamplePreferencesStore.getInstance()`, and exported for use by other parts of the extension. +Note that `examplePreferencesStore` is a singleton, calling this function again will not create a new store. The following example code, modified from the [`appPreferences` guide example](../renderer-extension#apppreferences) demonstrates how to use the extension store. `examplePreferencesStore` must be loaded in the main process, where loaded stores are automatically saved when exiting Lens. This can be done in `./main.ts`: @@ -87,7 +83,7 @@ export default class ExampleMainExtension extends LensMainExtension { } ``` -Here, `examplePreferencesStore.loadExtension(this)` is conveniently called from the `onActivate()` method of `ExampleMainExtension`. +Here, `examplePreferencesStore` is loaded with `examplePreferencesStore.loadExtension(this)`, which is conveniently called from the `onActivate()` method of `ExampleMainExtension`. Similarly, `examplePreferencesStore` must be loaded in the renderer process where the `appPreferences` are handled. This can be done in `./renderer.ts`: ``` typescript @@ -114,7 +110,7 @@ export default class ExampleRendererExtension extends LensRendererExtension { } ``` -Again, `examplePreferencesStore.loadExtension(this)` is called, this time from the `onActivate()` method of `ExampleRendererExtension`. +Again, `examplePreferencesStore.loadExtension(this)` is called to load `examplePreferencesStore`, this time from the `onActivate()` method of `ExampleRendererExtension`. Also, there is no longer the need for the `preference` field in the `ExampleRendererExtension` class, as the props for `ExamplePreferenceInput` is now `examplePreferencesStore`. `ExamplePreferenceInput` is defined in `./src/example-preference.tsx`: