You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#13593 included a specific help note for using the notices module data dispatch method in a WordPress context. I'd propose some improvements:
Consistency across modules which provide some data store, as far as documenting access to data behaviors (viewport is a similar "data-only" module, but same could be applied to any module's store)
Clarification that the data store is only registered if defined as a dependency to one's script
Clarification that dispatch is intended for effecting change, and including reference to data retrieval (i.e. select in addition to just a reference to dispatch).
I wonder if, for these modules, it might make sense to have a section specifically dedicated to usage in a WordPress context. Cordoning off in this way could prove to be a reasonable compromise between usefulness to a WordPress developer and respect toward the fact that these modules are published as standalone to npm.
Example:
## Usage in WordPress
In WordPress, the [x] module is [registered](https://developer.wordpress.org/reference/functions/wp_register_script/) using the `wp-[x]` script handle. When enqueuing your own scripts which make use of the [x] module, be sure to define this as a dependency.
In your JavaScript scripts, the public interface of the module can be referenced on the `window` global via `wp.[x]`.
To access [data methods](https://wordpress.org/gutenberg/handbook/designers-developers/developers/packages/packages-data/#data-access-and-manipulation) provided through the [x] module's registered store, reference it via the `core/[x]` namespace:
```js
wp.data.select( 'core/[x]' );
wp.data.dispatch( 'core/[x]' );
```
The text was updated successfully, but these errors were encountered:
There has been no conversation on this issue for two years, so it seems reasonable to close this request. If there is still a need to add to the documentation, please open a new issue with references to documentation as it exists today.
Continuation of #13593
Derived from #13592 (comment)
#13593 included a specific help note for using the notices module data
dispatch
method in a WordPress context. I'd propose some improvements:viewport
is a similar "data-only" module, but same could be applied to any module's store)dispatch
is intended for effecting change, and including reference to data retrieval (i.e.select
in addition to just a reference todispatch
).I wonder if, for these modules, it might make sense to have a section specifically dedicated to usage in a WordPress context. Cordoning off in this way could prove to be a reasonable compromise between usefulness to a WordPress developer and respect toward the fact that these modules are published as standalone to npm.
Example:
The text was updated successfully, but these errors were encountered: