question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider creating a central store package for managing and sharing state

See original GitHub issue

Feature Description

While reorganizing the packages from story-editor in #10452 we wanted to make elmements package to provide various APIs to register and retrieve element types and element-library package to be the library of elements available in the story editor. Currently, we use a simple array of elmentTypes in packages/story-editor/src/elements/elementTypes.js and we use the same array to get/create different element configurations using utility functions like getDefinitionForType, createNewElement, which is not ideal when we aim to register and share it between packages. We would also want to allow other consumers to register new element types so that they can create their own elements to be used in the story-editor in the future. We could create a custom react hook and make it a state however it would have a cascading effect on other parts of the code. ( see https://github.com/GoogleForCreators/web-stories-wp/pull/10452#discussion_r806699404 ).

Another instance was while moving meta boxes to wp-story-editor ( see #9027 ) for the decoupling efforts, we wanted to share some states like isSaving so that it can be accessed and modified by both story-editor and wp-story-editor but we had to use some workaround for it instead.

In a broader context, we may also want to allow other plugins ( for example Yoast SEO, etc ) to read and write data using javascript APIs which is currently not possible. So we should consider creating a central store like @wordpress/data which can also manage and share state between modules.

Alternatives Considered

We may use redux or redux-toolkit for this data package but needs discussion.

Additional Context

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:22 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
sayedtaquicommented, Mar 3, 2022

or has redux-toolkit already built exactly what we need & there’s no need to re-invent the wheel

That’s what it feels like to me, but it’s probably because I am less familiar with Zustand. I am exploring its docs to see what’s possible.

3reactions
swissspidycommented, Mar 2, 2022

cool cool. I feel like we could make this separate things then? Like have 1 task/epic to move necessary state management into a separate package, then a separate task/epic to convert what state we need from a provider based setup to store based setup. Thoughts?

Yeah absolutely, all this work can be split up into multiple tickets. But first we need to discuss and align on an approach, which this ticket is about. I’ll leave it up to the owning pod(s) to then split up work in a way that makes sense to them.

maybe best to do it selectively as needed vs wholesale?

👍


FYI, I asked @sayedtaqui to create small POC using Zustand just to get a better sense of what we’re trying to solve here / act as a base for further discussion. That doesn’t mean any decision on approach has been made or anything, nothing is set in stone.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create and manage Central Store - Windows Client
Describes how to create a Central Store on a domain controller to store and replicate registry-based policies for Windows.
Read more >
How to Configure Group Policy Central Store
In this post, you will learn how to configure and manage the group policy central store. What is the Group Policy Central Store?...
Read more >
Group Policy Central Store - 4sysops
The Group Policy Central Store allows Active Directory admins to keep the ADMX settings files updated, in one central location, ...
Read more >
HOWTO: Create a Group Policy Central Store - DirTeam.com
admx) and Group Policy Language (*.adml) files. The Central Store eliminates the loading and opening of Group Policy template files on systems ...
Read more >
React State Management for Enterprise Applications - Toptal
Problems may arise when the state should be shared among many components. Engineers have to find tools and libraries that suit their needs,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found