Skip to content

Commit

Permalink
Data Controls: Docs: Fix syntax errors and inaccurate usage example f…
Browse files Browse the repository at this point in the history
…or dispatch data control (#17773)

* Data Controls: Docs: Fix usage example for dispatch data control

* Data Controls: Docs: Resolve syntax errors in documented examples
  • Loading branch information
aduth authored and epiqueras committed Oct 4, 2019
1 parent 9230d0c commit 9030e51
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
6 changes: 6 additions & 0 deletions packages/data-controls/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Master

### Documentation

- Resolved syntax errors and inaccurate usage examples associated with `dispatch` function.

## 1.0.0 (2019-06-12)

Initial release of the @wordpress/data-controls package.
12 changes: 6 additions & 6 deletions packages/data-controls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ _Usage_
import { apiFetch } from '@wordpress/data-controls';

// Action generator using apiFetch
export function* myAction {
export function* myAction() {
const path = '/v2/my-api/items';
const items = yield apiFetch( { path } );
// do something with the items.
Expand Down Expand Up @@ -63,7 +63,7 @@ import * as selectors from './selectors';
import * as actions from './actions';
import * as resolvers from './resolvers';

registerStore ( 'my-custom-store', {
registerStore( 'my-custom-store', {
reducer,
controls,
actions,
Expand All @@ -86,9 +86,9 @@ _Usage_
import { dispatch } from '@wordpress/data-controls';

// Action generator using dispatch
export function* myAction {
yield dispatch( 'core/edit-post' ).togglePublishSidebar();
// do some other things.
export function* myAction() {
yield dispatch( 'core/edit-post', 'togglePublishSidebar' );
// do some other things.
}
```

Expand Down Expand Up @@ -116,7 +116,7 @@ _Usage_
import { select } from '@wordpress/data-controls';

// Action generator using select
export function* myAction {
export function* myAction() {
const isSidebarOpened = yield select( 'core/edit-post', 'isEditorSideBarOpened' );
// do stuff with the result from the select.
}
Expand Down
22 changes: 11 additions & 11 deletions packages/data-controls/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import { createRegistryControl } from '@wordpress/data';
* import { apiFetch } from '@wordpress/data-controls';
*
* // Action generator using apiFetch
* export function* myAction {
* const path = '/v2/my-api/items';
* const items = yield apiFetch( { path } );
* // do something with the items.
* export function* myAction() {
* const path = '/v2/my-api/items';
* const items = yield apiFetch( { path } );
* // do something with the items.
* }
* ```
*
Expand Down Expand Up @@ -46,9 +46,9 @@ export const apiFetch = ( request ) => {
* import { select } from '@wordpress/data-controls';
*
* // Action generator using select
* export function* myAction {
* const isSidebarOpened = yield select( 'core/edit-post', 'isEditorSideBarOpened' );
* // do stuff with the result from the select.
* export function* myAction() {
* const isSidebarOpened = yield select( 'core/edit-post', 'isEditorSideBarOpened' );
* // do stuff with the result from the select.
* }
* ```
*
Expand All @@ -75,9 +75,9 @@ export function select( storeKey, selectorName, ...args ) {
* import { dispatch } from '@wordpress/data-controls';
*
* // Action generator using dispatch
* export function* myAction {
* yield dispatch( 'core/edit-post' ).togglePublishSidebar();
* // do some other things.
* export function* myAction() {
* yield dispatch( 'core/edit-post', 'togglePublishSidebar' );
* // do some other things.
* }
* ```
*
Expand Down Expand Up @@ -141,7 +141,7 @@ const resolveSelect = ( registry, { storeKey, selectorName, args } ) => {
* import * as actions from './actions';
* import * as resolvers from './resolvers';
*
* registerStore ( 'my-custom-store', {
* registerStore( 'my-custom-store', {
* reducer,
* controls,
* actions,
Expand Down

0 comments on commit 9030e51

Please sign in to comment.