Skip to content

Commit

Permalink
Format recently added data package
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Mar 27, 2019
1 parent c741079 commit c4cadf2
Showing 1 changed file with 68 additions and 100 deletions.
168 changes: 68 additions & 100 deletions packages/data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,12 @@ Specific implementation differences from Redux and React Redux:

<!-- START TOKEN(Autogenerated API docs) -->

### combineReducers

[src/index.js#L58-L58](src/index.js#L58-L58)
<a name="combineReducers" href="#combineReducers">#</a> **combineReducers** [\<>](src/index.js#L58-L58)

The combineReducers helper function turns an object whose values are different
reducing functions into a single reducing function you can pass to registerReducer.

**Usage**
_Usage_

```js
const { combineReducers, registerStore } = wp.data;
Expand Down Expand Up @@ -283,157 +281,135 @@ registerStore( 'my-shop', {
} );
```

**Parameters**

- **reducers** `Object`: An object whose values correspond to different reducing functions that need to be combined into one.
_Parameters_

**Returns**
- _reducers_ `Object`: An object whose values correspond to different reducing functions that need to be combined into one.

`Function`: A reducer that invokes every reducer inside the reducers object, and constructs a state object with the same shape.
_Returns_

### createRegistry
- `Function`: A reducer that invokes every reducer inside the reducers object, and constructs a state object with the same shape.

[src/index.js#L17-L17](src/index.js#L17-L17)
<a name="createRegistry" href="#createRegistry">#</a> **createRegistry** [\<>](src/index.js#L17-L17)

Creates a new store registry, given an optional object of initial store
configurations.

**Parameters**
_Parameters_

- **storeConfigs** `Object`: Initial store configurations.
- _storeConfigs_ `Object`: Initial store configurations.

**Returns**
_Returns_

`WPDataRegistry`: Data registry.
- `WPDataRegistry`: Data registry.

### createRegistryControl

[src/index.js#L19-L19](src/index.js#L19-L19)
<a name="createRegistryControl" href="#createRegistryControl">#</a> **createRegistryControl** [\<>](src/index.js#L19-L19)

Mark a control as a registry control.

**Parameters**

- **registryControl** `function`: Function receiving a registry object and returning a control.
_Parameters_

**Returns**
- _registryControl_ `function`: Function receiving a registry object and returning a control.

`function`: marked registry control.
_Returns_

### createRegistrySelector
- `function`: marked registry control.

[src/index.js#L19-L19](src/index.js#L19-L19)
<a name="createRegistrySelector" href="#createRegistrySelector">#</a> **createRegistrySelector** [\<>](src/index.js#L19-L19)

Mark a selector as a registry selector.

**Parameters**
_Parameters_

- **registrySelector** `function`: Function receiving a registry object and returning a state selector.
- _registrySelector_ `function`: Function receiving a registry object and returning a state selector.

**Returns**
_Returns_

`function`: marked registry selector.
- `function`: marked registry selector.

### dispatch

[src/index.js#L92-L92](src/index.js#L92-L92)
<a name="dispatch" href="#dispatch">#</a> **dispatch** [\<>](src/index.js#L92-L92)

Given the name of a registered store, returns an object of the store's action creators.
Calling an action creator will cause it to be dispatched, updating the state value accordingly.

**Usage**
_Usage_

```js
const { dispatch } = wp.data;

dispatch( 'my-shop' ).setPrice( 'hammer', 9.75 );
```

**Parameters**

- **name** `string`: Store name
_Parameters_

**Returns**
- _name_ `string`: Store name

`Object`: Object containing the action creators.
_Returns_

### plugins
- `Object`: Object containing the action creators.

[src/index.js#L18-L18](src/index.js#L18-L18)
<a name="plugins" href="#plugins">#</a> **plugins** [\<>](src/index.js#L18-L18)

Undocumented declaration.

### registerGenericStore

[src/index.js#L122-L122](src/index.js#L122-L122)
<a name="registerGenericStore" href="#registerGenericStore">#</a> **registerGenericStore** [\<>](src/index.js#L122-L122)

Registers a generic store.

**Parameters**

- **key** `string`: Store registry key.
- **config** `Object`: Configuration (getSelectors, getActions, subscribe).
_Parameters_

### registerStore
- _key_ `string`: Store registry key.
- _config_ `Object`: Configuration (getSelectors, getActions, subscribe).

[src/index.js#L132-L132](src/index.js#L132-L132)
<a name="registerStore" href="#registerStore">#</a> **registerStore** [\<>](src/index.js#L132-L132)

Registers a standard `@wordpress/data` store.

**Parameters**
_Parameters_

- **reducerKey** `string`: Reducer key.
- **options** `Object`: Store description (reducer, actions, selectors, resolvers).
- _reducerKey_ `string`: Reducer key.
- _options_ `Object`: Store description (reducer, actions, selectors, resolvers).

**Returns**
_Returns_

`Object`: Registered store object.
- `Object`: Registered store object.

### RegistryConsumer

[src/index.js#L15-L15](src/index.js#L15-L15)
<a name="RegistryConsumer" href="#RegistryConsumer">#</a> **RegistryConsumer** [\<>](src/index.js#L15-L15)

Undocumented declaration.

### RegistryProvider

[src/index.js#L15-L15](src/index.js#L15-L15)
<a name="RegistryProvider" href="#RegistryProvider">#</a> **RegistryProvider** [\<>](src/index.js#L15-L15)

Undocumented declaration.

### select

[src/index.js#L76-L76](src/index.js#L76-L76)
<a name="select" href="#select">#</a> **select** [\<>](src/index.js#L76-L76)

Given the name of a registered store, returns an object of the store's selectors.
The selector functions are been pre-bound to pass the current state automatically.
As a consumer, you need only pass arguments of the selector, if applicable.

**Usage**
_Usage_

```js
const { select } = wp.data;

select( 'my-shop' ).getPrice( 'hammer' );
```

**Parameters**

- **name** `string`: Store name
_Parameters_

**Returns**
- _name_ `string`: Store name

`Object`: Object containing the store's selectors.
_Returns_

### subscribe
- `Object`: Object containing the store's selectors.

[src/index.js#L114-L114](src/index.js#L114-L114)
<a name="subscribe" href="#subscribe">#</a> **subscribe** [\<>](src/index.js#L114-L114)

Given a listener function, the function will be called any time the state value
of one of the registered stores has changed. This function returns a `unsubscribe`
function used to stop the subscription.

**Usage**
_Usage_

```js
const { subscribe } = wp.data;
Expand All @@ -447,23 +423,19 @@ const unsubscribe = subscribe( () => {
unsubscribe();
```

**Parameters**
_Parameters_

- **listener** `Function`: Callback function.
- _listener_ `Function`: Callback function.

### use

[src/index.js#L133-L133](src/index.js#L133-L133)
<a name="use" href="#use">#</a> **use** [\<>](src/index.js#L133-L133)

Undocumented declaration.

### withDispatch

[src/index.js#L13-L13](src/index.js#L13-L13)
<a name="withDispatch" href="#withDispatch">#</a> **withDispatch** [\<>](src/index.js#L13-L13)

Higher-order component used to add dispatch props using registered action creators.

**Usage**
_Usage_

```jsx
function Button( { onClick, children } ) {
Expand Down Expand Up @@ -517,37 +489,33 @@ const SaleButton = withDispatch( ( dispatch, ownProps, { select } ) => {

_Note:_ It is important that the `mapDispatchToProps` function always returns an object with the same keys. For example, it should not contain conditions under which a different value would be returned.

**Parameters**
_Parameters_

- **mapDispatchToProps** `Object`: Object of prop names where value is a dispatch-bound action creator, or a function to be called with with the component's props and returning an action creator.
- _mapDispatchToProps_ `Object`: Object of prop names where value is a dispatch-bound action creator, or a function to be called with with the component's props and returning an action creator.

**Returns**
_Returns_

`Component`: Enhanced component with merged dispatcher props.
- `Component`: Enhanced component with merged dispatcher props.

### withRegistry

[src/index.js#L14-L14](src/index.js#L14-L14)
<a name="withRegistry" href="#withRegistry">#</a> **withRegistry** [\<>](src/index.js#L14-L14)

Higher-order component which renders the original component with the current
registry context passed as its `registry` prop.

**Parameters**

- **OriginalComponent** `WPComponent`: Original component.
_Parameters_

**Returns**
- _OriginalComponent_ `WPComponent`: Original component.

`WPComponent`: Enhanced component.
_Returns_

### withSelect
- `WPComponent`: Enhanced component.

[src/index.js#L12-L12](src/index.js#L12-L12)
<a name="withSelect" href="#withSelect">#</a> **withSelect** [\<>](src/index.js#L12-L12)

Higher-order component used to inject state-derived props using registered
selectors.

**Usage**
_Usage_

```js
function PriceDisplay( { price, currency } ) {
Expand Down Expand Up @@ -575,13 +543,13 @@ const HammerPriceDisplay = withSelect( ( select, ownProps ) => {

In the above example, when `HammerPriceDisplay` is rendered into an application, it will pass the price into the underlying `PriceDisplay` component and update automatically if the price of a hammer ever changes in the store.

**Parameters**
_Parameters_

- **mapSelectToProps** `Function`: Function called on every state change, expected to return object of props to merge with the component's own props.
- _mapSelectToProps_ `Function`: Function called on every state change, expected to return object of props to merge with the component's own props.

**Returns**
_Returns_

`Component`: Enhanced component with merged state data props.
- `Component`: Enhanced component with merged state data props.


<!-- END TOKEN(Autogenerated API docs) -->
Expand Down

0 comments on commit c4cadf2

Please sign in to comment.