[Discuss] Global / Shared state plugin #58721
Labels
discuss
Feature:StateManagement
impact:low
Addressing this issue will have a low level of impact on the quality/strength of our product.
loe:small
Small Level of Effort
triage_needed
In NP there is no concept of
GlobalState
. Plugins have their internal state which is preserved during navigation within different apps. #39855Without doubting benefits of this approach, there are also some rare use cases, where an abstraction similar to
GlobalState
would be helpful.For example: rendering url to a different place inside Kibana.
Whenever such URL is rendered, apps should not forget to pull from the plugins and serialise any important state into the URL.
Basically to render a link to a different place in kibana, app have to do something like this:
The link should also be re-rendered whenever any of the dependencies change.
Another use case is syncing state with browser location.
Kibana apps sync
data
plugin's state into the url and we introduced useful observable to subscribe for changes to data plugin's state which merges states from different data plugin's services #57168 . Then apps wire it up to browser location syncing. @ppisljar pointed out problems with this approach: this helper is local todata
plugin and it won't work anymore if we split data plugin's services into multiple separate plugins or if we have plugin's state to sync to url along withdata
plugin's state and app's state.So maybe worth consider building a plugin for registering such global state pieces. And this plugin will provide apps with single observable for state pieces that need to be serialised into rendered urls (or synced to browser location). This will lift off the burden from apps to make all the orchestration of different states on their own.
The flow would look something like this:
This probably could also be helpful for current sub-url-tracking solution. Since it uses
data
plugin'sstate$
observable. And this plugin would be a more generic replacement fordata's
specific use case.This probably is more generic replacement of - Implement data.query service observables to track state changes #57168
The text was updated successfully, but these errors were encountered: