From 51f7fc52d7bcbe052a84b2352a02ea326c504f70 Mon Sep 17 00:00:00 2001 From: Jarda Snajdr Date: Wed, 30 Sep 2020 12:16:03 +0200 Subject: [PATCH] Mark the deprecated controls as deprecated --- packages/data-controls/CHANGELOG.md | 5 +++++ packages/data-controls/README.md | 12 ++++++++++ packages/data-controls/package.json | 3 ++- packages/data-controls/src/index.js | 35 ++++++++++++++++++++++++----- 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/packages/data-controls/CHANGELOG.md b/packages/data-controls/CHANGELOG.md index 7c95215fe630ec..2fdf3382911e96 100644 --- a/packages/data-controls/CHANGELOG.md +++ b/packages/data-controls/CHANGELOG.md @@ -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 diff --git a/packages/data-controls/README.md b/packages/data-controls/README.md index a2379d86c158d5..d9a346956e00c9 100644 --- a/packages/data-controls/README.md +++ b/packages/data-controls/README.md @@ -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. + # **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. + # **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. + diff --git a/packages/data-controls/package.json b/packages/data-controls/package.json index 998c715c311a1a..d0c603aef879c7 100644 --- a/packages/data-controls/package.json +++ b/packages/data-controls/package.json @@ -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" diff --git a/packages/data-controls/src/index.js b/packages/data-controls/src/index.js index 6e6e30299c6f73..a789a197b5a5f1 100644 --- a/packages/data-controls/src/index.js +++ b/packages/data-controls/src/index.js @@ -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. @@ -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