Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[D&D] Add state management for the Drag & Drop plugin #947

Closed
ashwin-pc opened this issue Nov 17, 2021 · 1 comment
Closed

[D&D] Add state management for the Drag & Drop plugin #947

ashwin-pc opened this issue Nov 17, 2021 · 1 comment
Assignees

Comments

@ashwin-pc
Copy link
Member

Add state management to the drag and drop plugin

@ashwin-pc
Copy link
Member Author

Options being considered:

Recommendation

Redux with React Redux and Redux toolkit.

Why not State containers?

State containers are a custom solution for state management within a plugin for OpenSearch Dashboards meant to closely mimic Redux without the boiler plate. Based on the State container docs, State containers are Redux-store-like objects meant to help you manage state in your services or apps. While this was useful when it was initially created, Redux has come a long way to address some of those shortfalls while also giving us access to all its features and ecosystem that it warrants another look.

All of the reasons mentioned in the Sate container doc are no longer true about redux and can be easily achieved by Redux Toolkit e.g. Strongly typed, less boilerplate code, ability to use with and without react. It also lacks some of the benefits that redux provides such as time travel, extensions, developer tools and documentation.

Why Redux

Redux is the oldest and most popular state management tool for react applications. It can be used without it too and comes with a very opinionated style and large ecosystem of tools and features. While it is not recommended for many simple use-cases for state management, more complex applications and larger code bases with large amounts of application state can definitely benefit from it. State containers were after all modeled to mimic redux after all. Like any tool however redux does have some trade offs:

  • Application state should be described using plain JS objects and arrays
  • There must be a single Redux store that holds the application state
  • The store can only be updated by describing events that happen as plain "action" objects, and "dispatching" them to the store for processing
  • The logic for updating the store state must be written as "reducer" functions, which look at the current state and the action object to decide what the resulting new state should be. Reducer functions must be "pure", with no side effects, and must calculate the new state using immutable updates.
  • More boiler plate code

Some of these tradeoff are acceptable to our use-case but most of them are no longer an issue when we use it in combination with redux toolkit.

Redux with React Redux and Redux Toolkit offers all the benefits that come with State containers, while also providing us with additional features such as Slices, Time travel, extensions, Immutability. It also comes with a lot more tooling and documentation that makes working with it a lot easier.

AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this issue Feb 10, 2022
…pensearch-project#947)

refactor: saving the tree path information in the tree nodes; legend item sorting based on the path; code simplifications; minor perf improvements

fix opensearch-project#944
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this issue Feb 10, 2022
# [24.5.0](elastic/elastic-charts@v24.4.0...v24.5.0) (2021-01-30)

### Bug Fixes

* add theme min radius to point shape ([opensearch-project#996](elastic/elastic-charts#996)) ([98089a9](elastic/elastic-charts@98089a9))
* align tooltip z-index to EUI tooltip z-index ([opensearch-project#931](elastic/elastic-charts#931)) ([f7f1f6f](elastic/elastic-charts@f7f1f6f))
* chart state and series functions cleanup ([opensearch-project#989](elastic/elastic-charts#989)) ([42a7af0](elastic/elastic-charts@42a7af0))
* create unique ids for dot icons ([opensearch-project#971](elastic/elastic-charts#971)) ([0b3e00f](elastic/elastic-charts@0b3e00f))
* external tooltip legend extra value sync ([opensearch-project#993](elastic/elastic-charts#993)) ([7e1096e](elastic/elastic-charts@7e1096e))
* **legend:** disable focus and keyboard navigation for legend in partition ch… ([opensearch-project#952](elastic/elastic-charts#952)) ([dfff3e2](elastic/elastic-charts@dfff3e2))
* **legend:** hierarchical legend order should follow the tree paths ([opensearch-project#947](elastic/elastic-charts#947)) ([7b70186](elastic/elastic-charts@7b70186)), closes [opensearch-project#944](elastic/elastic-charts#944)
* **legend:** remove ids for circles ([opensearch-project#973](elastic/elastic-charts#973)) ([ed98481](elastic/elastic-charts@ed98481))

### Features

* **cursor:** improve theme styling for crosshair ([opensearch-project#980](elastic/elastic-charts#980)) ([0248ad6](elastic/elastic-charts@0248ad6))
* **legend:**  display pie chart legend extra ([opensearch-project#939](elastic/elastic-charts#939)) ([672a4df](elastic/elastic-charts@672a4df))
* **legend:** add keyboard navigation ([opensearch-project#880](elastic/elastic-charts#880)) ([b471a94](elastic/elastic-charts@b471a94))
* **partition:** Flame and icicle chart ([opensearch-project#965](elastic/elastic-charts#965)) ([9e8b1f7](elastic/elastic-charts@9e8b1f7))
* **partition:** legend hover options ([opensearch-project#978](elastic/elastic-charts#978)) ([acd1339](elastic/elastic-charts@acd1339))
* **xy:** support multiple point shapes on line, area and bubble charts ([opensearch-project#988](elastic/elastic-charts#988)) ([4f23b4f](elastic/elastic-charts@4f23b4f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant