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

Documentation: Consistency for module WordPress context usage #13674

Closed
aduth opened this issue Feb 5, 2019 · 2 comments
Closed

Documentation: Consistency for module WordPress context usage #13674

aduth opened this issue Feb 5, 2019 · 2 comments
Labels
[Type] Developer Documentation Documentation for developers

Comments

@aduth
Copy link
Member

aduth commented Feb 5, 2019

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:

  • 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]' );
```
@paaljoachim
Copy link
Contributor

Is this issue still relevant?

@mkaz

@DaisyOlsen
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Developer Documentation Documentation for developers
3 participants