You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: dev_docs/key_concepts/persistable_state.mdx
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,22 +7,22 @@ date: 2021-02-02
7
7
tags: ['kibana','dev', 'contributor', 'api docs']
8
8
---
9
9
10
-
“Persistable state” is developer-defined state that supports being persisted by a plugin other than the one defining it. Persistable State needs to be serializable and the owner can/should provide utilities to migrate it, extract and inject references from/to it, as well as telemetry collection utilities.
10
+
“Persistable state” is developer-defined state that supports being persisted by a plugin other than the one defining it. Persistable State needs to be serializable and the owner can/should provide utilities to migrate it, extract and inject any <DocLinkid="kibDevDocsSavedObjectsIntro"section="references"text="references to Saved Objects"/> it may contain, as well as telemetry collection utilities.
11
11
12
12
## Exposing state that can be persisted
13
13
14
-
Any plugin that exposes state that another plugin might persist should implement `PersistableStateService` interface on their `setup` contract. This will allow plugins persisting the state to easily access migrations and other utilities.
14
+
Any plugin that exposes state that another plugin might persist should implement <DocLinkid="kibKibanaUtilsPluginApi "section="def-common.PersistableStateService"text="`PersistableStateService`"/> interface on their `setup` contract. This will allow plugins persisting the state to easily access migrations and other utilities.
15
15
16
16
Example: Data plugin allows you to generate filters. Those filters can be persisted by applications in their saved
17
-
objects or in the URL. In order to allow apps to migrate the filters in case the structure changes in the future, the Data plugin implements `PersistableStateService` on `data.query.filterManager`.
17
+
objects or in the URL. In order to allow apps to migrate the filters in case the structure changes in the future, the Data plugin implements `PersistableStateService` on <DocLinkid="kibDataQueryPluginApi "section="def-public.FilterManager"text="`data.query.filterManager`"/>.
18
18
19
19
note: There is currently no obvious way for a plugin to know which state is safe to persist. The developer must manually look for a matching `PersistableStateService`, or ad-hoc provided migration utilities (as is the case with Rule Type Parameters).
20
20
In the future, we hope to make it easier for producers of state to understand when they need to write a migration with changes, and also make it easier for consumers of such state, to understand whether it is safe to persist.
21
21
22
22
## Exposing state that can be persisted but is not owned by plugin exposing it (registry)
23
23
24
24
Any plugin that owns collection of items (registry) whose state/configuration can be persisted should implement `PersistableStateService`
25
-
interface on their `setup` contract and each item in the collection should implement `PersistableStateDefinition` interface.
25
+
interface on their `setup` contract and each item in the collection should implement <DocLinkid="kibKibanaUtilsPluginApi"section="def-common.PersistableStateDefinition"text="`PersistableStateDefinition`"/> interface.
26
26
27
27
Example: Embeddable plugin owns the registry of embeddable factories to which other plugins can register new embeddable factories. Dashboard plugin
28
28
stores a bunch of embeddable panels input in its saved object and URL. Embeddable plugin setup contract implements `PersistableStateService`
note: if your plugin doesn't expose the state (is the only one storing state)plugin doesn't need to implement `PersistableStateService` interface.
43
+
Note: if your plugin doesn't expose the state (it is the only one storing state), the plugin doesn't need to implement the`PersistableStateService` interface.
44
44
If the state your plugin is storing can be provided by other plugins (your plugin owns a registry) items in that registry still need to implement `PersistableStateDefinition` interface.
45
45
46
46
## Storing persistable state as part of saved object
@@ -62,7 +62,7 @@ note: Currently there is no recommended way on how to store version in url and i
62
62
### Extraction/Injection of References
63
63
64
64
In order to support import and export, and space-sharing capabilities, Saved Objects need to explicitly list any references they contain to other Saved Objects.
65
-
To support persisting your state in saved objects owned by another plugin, the `extract` and `inject` methods of Persistable State interface should be implemented.
65
+
To support persisting your state in saved objects owned by another plugin, the <DocLinkid="kibKibanaUtilsPluginApi"section="def-common.PersistableState.extract"text="`extract`"/> and <DocLinkid="kibKibanaUtilsPluginApi"section="def-common.PersistableState.inject"text="`inject`"/> methods of Persistable State interface should be implemented.
66
66
67
67
<DocLinkid="kibDevTutorialSavedObject"section="references"text="Learn how to define Saved Object references"/>
68
68
@@ -80,4 +80,4 @@ As your plugin evolves, you may need to change your state in a breaking way. If
80
80
81
81
## Telemetry
82
82
83
-
You might want to collect state about how your state is used. If that is the case you should implement the telemetry method of Persistable State interface.
83
+
You might want to collect statistics about how your state is used. If that is the case you should implement the telemetry method of Persistable State interface.
0 commit comments