-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Data: Allow passing store definitions to controls #34170
Conversation
Size Change: -19 B (0%) Total Size: 1.04 MB
ℹ️ View Unchanged
|
142c1ea
to
2c1136a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this.
function select( storeNameOrDefinition, selectorName, ...args ) { | ||
return { | ||
type: SELECT, | ||
storeKey: isObject( storeNameOrDefinition ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially this check could be moved to the implementation of the control itself. Actually, I wonder if it's needed at all since this should just call registry.select
which handles both already right? (same for the others)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are probably correct. There are some levels of indirection here so I would have to do a second pass of refactorings. I will merge this PR and open another one. I suspect that some unit tests will have to be revised so they work with storeKey
as an object. I also wasn't sure if I can update storeKey
key.
Description
Related to #34155.
Follow-up for #27548.
Updates data controls to accept a data store definition as their first param in addition to a string-based store name value. It aligns with the changes introduced in #27548 and is mostly for consistency.
Updated methods that can be imported from
@wordpress.data
with:select
resolveSelect
dispatch
How has this been tested?
Unit and e2e tests should still pass.
Types of changes
API enahcnement for
@wordpress/data
and controls.Checklist:
*.native.js
files for terms that need renaming or removal).