-
Notifications
You must be signed in to change notification settings - Fork 295
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
Refactor actions and resolvers with wp.data
controls
#8992
Comments
@zutigrm Let's do the opposite, starting with one module. That way the number of files/modules/etc. to test/review is smaller, and the QA can be scoped to testing Analytics behaviour. If during development there's time to work on more modules they can be added I think. It's missing from the ACs, but part of this change should include us exporting these new controls from I think we can mirror the
I get what this means but it's a bit hard to read/parse. I think it's fine to write something like:
|
I just want to flag that the example here is incorrect. The As mentioned in the description:
Calling the function returns the raw action object, so we need to wpd.controls.select('store/foo', 'getBar', 'argBaz', 'argBuzz')
// returns:
{
type: '@@data/SELECT',
storeKey: 'store/foo',
selectorName: 'getBar',
args: [ 'argBaz', 'argBuzz' ]
} |
Thanks @aaemnnosttv indeed, I updated to reference that they should be yielded to return the result. @tofumatt Thanks for the suggestion, I update IB to mention adding alias for controls to our data package, and applied suggested wording. |
We should be explicit in the IB that not all site-kit-wp/assets/js/googlesitekit/data/create-existing-tag-store.js Lines 103 to 104 in dc89f6c
Let's also make a plan to mark |
Thanks @tofumatt , that's a good spot. I amended the IB to include those points. I suggested the depreciation error for eslint rule to ensure it is not used. Let me know what you think |
I meant a JSDoc I adjusted the IB to account for this, and increased the estimate slightly in case any issues are encountered; if they aren't, more work can be done on other stores. IB ✅ |
After a discussion with @aaemnnosttv, @eugene-manuilov, and @nfmohit, we're actually going to change the scope of this issue after looking at the resulting PR (#9234), which ends up being a worse API 😅 I'm just updating that PR and will move it to CR soon; I've updated the ACs accordingly. |
No QA to do here, moving to approval 👍 |
Feature Description
With our recent upgrade of
@wordpress/data
, the package now includes a set ofcontrols
which are essentially utility actions that every store will have associatedcontrols
for.These are
select
– Dispatches a control action for triggering a synchronous registry select.resolveSelect
– Dispatches a control action for triggering and resolving a registry select.dispatch
– Dispatches a control action for triggering a registry dispatch.These are actions meaning we would
yield
these within our own actions/resolvers instead of using workarounds togetRegistry
andcommonActions.await
just to get access toselect
/registrySelect
ordispatch
andawait
the result.Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
select
,resolveSelect
, anddispatch
) in ourgooglesitekit-data
packageImplementation Brief
AdSense
module to use the newbuiltInControls
instead of thegetRegistry
common actions. Follow-up issues should be filed to continue to the next module, unless there is time to fit another module in same issue (based on the issue estimate).assets/js/googlesitekit/data/index.js
controls
to the existing imports list from@wordpress/data
, and alias it asbuiltInControls
builtInControls
to the exportsite-kit-wp/assets/js/googlesitekit/data/index.js
Lines 74 to 100 in 2b31bf5
import { builtInControls } from 'googlesitekit-data'
and replace the usage ofawait
,registry
and itsselect
,resolveSelect
anddispatch
in the actions and resolvers, with the builtin controls:yield select( storeKey, selectorName, ...args )
, so replaceregistry.select
withyield builtInControls.select
,registry.resolveSelect
withyield builtInControls.resolveSelect
, andregistry.dispatch
withyield builtInControls.dispatch
builtInControls
object will hold all three controls{select, resolveSelect, dispatch}
commonActions
, we should leave it if it is a passed prop fromcreateRegistryControl
, like heresite-kit-wp/assets/js/modules/analytics-4/datastore/properties.js
Line 740 in 9306906
site-kit-wp/assets/js/googlesitekit/data/create-existing-tag-store.js
Lines 103 to 104 in dc89f6c
site-kit-wp/assets/js/googlesitekit/data/utils.js
Line 219 in bea308e
@deprecated
in JSDoc; no new usage of these actions should be introduced.AdSense
.Test Coverage
QA Brief
googlesitekit-data
.Changelog entry
googlesitekit-data
.The text was updated successfully, but these errors were encountered: