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

Add registry-aware controls #13722

Merged
merged 1 commit into from
Feb 8, 2019
Merged

Conversation

youknowriad
Copy link
Contributor

Related #13662 Requirement for #13088

In some situations, you want to build controls that target another store from the registry. Until now we were relying on the global select or dispatch functions but the issue is that it only targets the default registry. If we have a separate provider, this might not work as expected. In this PR, I'm introducing a createRegistryControl helper used to mark a control a cross-stores control with access to the registry object.

const controls = {
   TYPE_OF_CONTROL: createRegistryControl( registry => (args) => {
      // Do something with registry
   })
}

This PR also includes a follow-up performance improvement to the registry-aware selectors.

@youknowriad youknowriad added Framework Issues related to broader framework topics, especially as it relates to javascript [Package] Data /packages/data labels Feb 7, 2019
@youknowriad youknowriad added this to the 5.1 (Gutenberg) milestone Feb 7, 2019
@youknowriad youknowriad self-assigned this Feb 7, 2019
Copy link
Contributor

@nerrad nerrad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

packages/data/src/namespace-store.js Outdated Show resolved Hide resolved
@aduth
Copy link
Member

aduth commented Feb 7, 2019

This all seems sensible to me, but I've got some burrowed worry about how this actually works, when we'd have some separate RegistryProvider. I guess it might rely on some registry clone behavior like considered in #7453, which would re-assign the registry for the selectors / controls in the process of undergoing the clone?

@youknowriad
Copy link
Contributor Author

@aduth That's a good point, I thought about it and yes it's challenging if we map the selectors and controls inside the store creation funciton. It means the clone function needs to reassign the selectors/controls somehow while if done at the registry level It would be generic, easily clonable but at the same time a little bit less performant.

I think this should be reconsidered as part of the "clone" implementation and whether the performance gain in long posts is important enough to be worth the added complexity.

@youknowriad youknowriad force-pushed the add/registry-aware-controls branch from ea64095 to 8b07508 Compare February 8, 2019 08:09
@youknowriad youknowriad merged commit 9632d34 into master Feb 8, 2019
@youknowriad youknowriad deleted the add/registry-aware-controls branch February 8, 2019 09:13
youknowriad added a commit that referenced this pull request Mar 6, 2019
youknowriad added a commit that referenced this pull request Mar 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Framework Issues related to broader framework topics, especially as it relates to javascript [Package] Data /packages/data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants