Skip to content

Commit

Permalink
Mark the deprecated controls as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr committed Sep 30, 2020
1 parent c2afe8b commit 51f7fc5
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 6 deletions.
5 changes: 5 additions & 0 deletions packages/data-controls/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

- Expose the `syncSelect` control for synchronous calls of registry selectors

### Deprecations

- Deprecated the `syncSelect`, `select` and `dispatch` controls that are now part of
`@wordpress/data` and built in by default in every data store.

## 1.4.0 (2019-11-14)

### Documentation
Expand Down
12 changes: 12 additions & 0 deletions packages/data-controls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,27 @@ _Returns_
Control for dispatching an action in a registered data store.
Alias for the `dispatch` control in the `@wordpress/data` package.

_Parameters_

- _args_ `Array`: Arguments passed without change to the `@wordpress/data` control.

<a name="select" href="#select">#</a> **select**

Control for resolving a selector in a registered data store.
Alias for the `resolveSelect` built-in control in the `@wordpress/data` package.

_Parameters_

- _args_ `Array`: Arguments passed without change to the `@wordpress/data` control.

<a name="syncSelect" href="#syncSelect">#</a> **syncSelect**

Control for calling a selector in a registered data store.
Alias for the `select` built-in control in the `@wordpress/data` package.

_Parameters_

- _args_ `Array`: Arguments passed without change to the `@wordpress/data` control.


<!-- END TOKEN(Autogenerated API docs) -->
3 changes: 2 additions & 1 deletion packages/data-controls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"react-native": "src/index",
"dependencies": {
"@wordpress/api-fetch": "file:../api-fetch",
"@wordpress/data": "file:../data"
"@wordpress/data": "file:../data",
"@wordpress/deprecated": "file:../deprecated"
},
"publishConfig": {
"access": "public"
Expand Down
35 changes: 30 additions & 5 deletions packages/data-controls/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import triggerFetch from '@wordpress/api-fetch';
import { controls as dataControls } from '@wordpress/data';
import deprecated from '@wordpress/deprecated';

/**
* Dispatches a control action for triggering an api fetch call.
Expand All @@ -23,30 +24,54 @@ import { controls as dataControls } from '@wordpress/data';
*
* @return {Object} The control descriptor.
*/
export const apiFetch = ( request ) => {
export function apiFetch( request ) {
return {
type: 'API_FETCH',
request,
};
};
}

/**
* Control for resolving a selector in a registered data store.
* Alias for the `resolveSelect` built-in control in the `@wordpress/data` package.
*
* @param {Array} args Arguments passed without change to the `@wordpress/data` control.
*/
export const select = dataControls.resolveSelect;
export function select( ...args ) {
deprecated( '`select` control in `@wordpress/data-controls`', {
alternative: 'built-in `resolveSelect` control in `@wordpress/data`',
} );

return dataControls.resolveSelect( ...args );
}

/**
* Control for calling a selector in a registered data store.
* Alias for the `select` built-in control in the `@wordpress/data` package.
*
* @param {Array} args Arguments passed without change to the `@wordpress/data` control.
*/
export const syncSelect = dataControls.select;
export function syncSelect( ...args ) {
deprecated( '`syncSelect` control in `@wordpress/data-controls`', {
alternative: 'built-in `select` control in `@wordpress/data`',
} );

return dataControls.select( ...args );
}

/**
* Control for dispatching an action in a registered data store.
* Alias for the `dispatch` control in the `@wordpress/data` package.
*
* @param {Array} args Arguments passed without change to the `@wordpress/data` control.
*/
export const dispatch = dataControls.dispatch;
export function dispatch( ...args ) {
deprecated( '`dispatch` control in `@wordpress/data-controls`', {
alternative: 'built-in `dispatch` control in `@wordpress/data`',
} );

return dataControls.dispatch( ...args );
}

/**
* The default export is what you use to register the controls with your custom
Expand Down

0 comments on commit 51f7fc5

Please sign in to comment.