@wordpress/data
Advanced tools
Comparing version 4.26.8 to 4.27.0
@@ -143,3 +143,3 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
args = _ref2.args; | ||
var method = registry.select(storeKey)[selectorName].hasResolver ? '__experimentalResolveSelect' : 'select'; | ||
var method = registry.select(storeKey)[selectorName].hasResolver ? 'resolveSelect' : 'select'; | ||
return (_registry$method = registry[method](storeKey))[selectorName].apply(_registry$method, _toConsumableArray(args)); | ||
@@ -146,0 +146,0 @@ }; |
@@ -103,5 +103,5 @@ /** | ||
* ```js | ||
* import { __experimentalResolveSelect } from '@wordpress/data'; | ||
* import { resolveSelect } from '@wordpress/data'; | ||
* | ||
* __experimentalResolveSelect( 'my-shop' ).getPrice( 'hammer' ).then(console.log) | ||
* resolveSelect( 'my-shop' ).getPrice( 'hammer' ).then(console.log) | ||
* ``` | ||
@@ -112,3 +112,3 @@ * | ||
export var __experimentalResolveSelect = defaultRegistry.__experimentalResolveSelect; | ||
export var resolveSelect = defaultRegistry.resolveSelect; | ||
/** | ||
@@ -115,0 +115,0 @@ * Given the name of a registered store, returns an object of the store's action creators. |
@@ -146,2 +146,4 @@ import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
var resolveSelectors = mapResolveSelectors(selectors, store); | ||
var getSelectors = function getSelectors() { | ||
@@ -156,3 +158,3 @@ return selectors; | ||
var getResolveSelectors = function getResolveSelectors() { | ||
return mapResolveSelectors(selectors, store); | ||
return resolveSelectors; | ||
}; // We have some modules monkey-patching the store object | ||
@@ -195,3 +197,3 @@ // It's wrong to do so but until we refactor all of our effects to controls | ||
getSelectors: getSelectors, | ||
__experimentalGetResolveSelectors: getResolveSelectors, | ||
getResolveSelectors: getResolveSelectors, | ||
getActions: getActions, | ||
@@ -198,0 +200,0 @@ subscribe: subscribe |
@@ -132,3 +132,3 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
function __experimentalResolveSelect(storeNameOrDefinition) { | ||
function resolveSelect(storeNameOrDefinition) { | ||
var storeName = isObject(storeNameOrDefinition) ? storeNameOrDefinition.name : storeNameOrDefinition; | ||
@@ -141,6 +141,6 @@ | ||
if (store) { | ||
return store.__experimentalGetResolveSelectors(); | ||
return store.getResolveSelectors(); | ||
} | ||
return parent && parent.__experimentalResolveSelect(storeName); | ||
return parent && parent.resolveSelect(storeName); | ||
} | ||
@@ -249,3 +249,3 @@ /** | ||
select: select, | ||
__experimentalResolveSelect: __experimentalResolveSelect, | ||
resolveSelect: resolveSelect, | ||
dispatch: dispatch, | ||
@@ -252,0 +252,0 @@ use: use, |
@@ -152,3 +152,3 @@ "use strict"; | ||
args = _ref2.args; | ||
var method = registry.select(storeKey)[selectorName].hasResolver ? '__experimentalResolveSelect' : 'select'; | ||
var method = registry.select(storeKey)[selectorName].hasResolver ? 'resolveSelect' : 'select'; | ||
return (_registry$method = registry[method](storeKey))[selectorName].apply(_registry$method, (0, _toConsumableArray2.default)(args)); | ||
@@ -155,0 +155,0 @@ }; |
@@ -100,3 +100,3 @@ "use strict"; | ||
}); | ||
exports.plugins = exports.register = exports.use = exports.registerStore = exports.registerGenericStore = exports.subscribe = exports.dispatch = exports.__experimentalResolveSelect = exports.select = void 0; | ||
exports.plugins = exports.register = exports.use = exports.registerStore = exports.registerGenericStore = exports.subscribe = exports.dispatch = exports.resolveSelect = exports.select = void 0; | ||
@@ -219,5 +219,5 @@ var _turboCombineReducers = _interopRequireDefault(require("turbo-combine-reducers")); | ||
* ```js | ||
* import { __experimentalResolveSelect } from '@wordpress/data'; | ||
* import { resolveSelect } from '@wordpress/data'; | ||
* | ||
* __experimentalResolveSelect( 'my-shop' ).getPrice( 'hammer' ).then(console.log) | ||
* resolveSelect( 'my-shop' ).getPrice( 'hammer' ).then(console.log) | ||
* ``` | ||
@@ -229,3 +229,3 @@ * | ||
exports.select = select; | ||
var __experimentalResolveSelect = _defaultRegistry.default.__experimentalResolveSelect; | ||
var resolveSelect = _defaultRegistry.default.resolveSelect; | ||
/** | ||
@@ -250,3 +250,3 @@ * Given the name of a registered store, returns an object of the store's action creators. | ||
exports.__experimentalResolveSelect = __experimentalResolveSelect; | ||
exports.resolveSelect = resolveSelect; | ||
var dispatch = _defaultRegistry.default.dispatch; | ||
@@ -253,0 +253,0 @@ /** |
@@ -159,2 +159,4 @@ "use strict"; | ||
var resolveSelectors = mapResolveSelectors(selectors, store); | ||
var getSelectors = function getSelectors() { | ||
@@ -169,3 +171,3 @@ return selectors; | ||
var getResolveSelectors = function getResolveSelectors() { | ||
return mapResolveSelectors(selectors, store); | ||
return resolveSelectors; | ||
}; // We have some modules monkey-patching the store object | ||
@@ -208,3 +210,3 @@ // It's wrong to do so but until we refactor all of our effects to controls | ||
getSelectors: getSelectors, | ||
__experimentalGetResolveSelectors: getResolveSelectors, | ||
getResolveSelectors: getResolveSelectors, | ||
getActions: getActions, | ||
@@ -211,0 +213,0 @@ subscribe: subscribe |
@@ -137,3 +137,3 @@ "use strict"; | ||
function __experimentalResolveSelect(storeNameOrDefinition) { | ||
function resolveSelect(storeNameOrDefinition) { | ||
var storeName = (0, _lodash.isObject)(storeNameOrDefinition) ? storeNameOrDefinition.name : storeNameOrDefinition; | ||
@@ -146,6 +146,6 @@ | ||
if (store) { | ||
return store.__experimentalGetResolveSelectors(); | ||
return store.getResolveSelectors(); | ||
} | ||
return parent && parent.__experimentalResolveSelect(storeName); | ||
return parent && parent.resolveSelect(storeName); | ||
} | ||
@@ -254,3 +254,3 @@ /** | ||
select: select, | ||
__experimentalResolveSelect: __experimentalResolveSelect, | ||
resolveSelect: resolveSelect, | ||
dispatch: dispatch, | ||
@@ -257,0 +257,0 @@ use: use, |
@@ -5,2 +5,8 @@ <!-- Learn how to maintain this file at https://github.com/WordPress/gutenberg/tree/HEAD/packages#maintaining-changelogs. --> | ||
## 4.27.0 (2021-03-17) | ||
### New Features | ||
- Added new `resolveSelect` registry method to initiate and wait for selector resolution | ||
## 4.26.0 (2020-12-17) | ||
@@ -7,0 +13,0 @@ |
{ | ||
"name": "@wordpress/data", | ||
"version": "4.26.8", | ||
"version": "4.27.0", | ||
"description": "Data module for WordPress.", | ||
@@ -28,8 +28,8 @@ "author": "The WordPress Contributors", | ||
"@babel/runtime": "^7.12.5", | ||
"@wordpress/compose": "^3.24.5", | ||
"@wordpress/deprecated": "^2.11.1", | ||
"@wordpress/element": "^2.19.1", | ||
"@wordpress/is-shallow-equal": "^3.0.1", | ||
"@wordpress/priority-queue": "^1.10.1", | ||
"@wordpress/redux-routine": "^3.13.1", | ||
"@wordpress/compose": "^3.25.0", | ||
"@wordpress/deprecated": "^2.12.0", | ||
"@wordpress/element": "^2.20.0", | ||
"@wordpress/is-shallow-equal": "^3.1.0", | ||
"@wordpress/priority-queue": "^1.11.0", | ||
"@wordpress/redux-routine": "^3.14.0", | ||
"equivalent-key-map": "^0.2.2", | ||
@@ -46,3 +46,3 @@ "is-promise": "^4.0.0", | ||
}, | ||
"gitHead": "a56ed29096f92fe434f9f0a88d9ab76479ee5ec1" | ||
"gitHead": "054f7d722fe561b2bede2d1e89e1add59a6b7093" | ||
} |
@@ -388,3 +388,3 @@ # Data | ||
- _storeConfigs_ `Object`: Initial store configurations. | ||
- _parent_ `?Object`: Parent registry. | ||
- _parent_ `Object?`: Parent registry. | ||
@@ -488,3 +488,3 @@ _Returns_ | ||
- _storeNameOrDefinition_ `(string|WPDataStore)`: Unique namespace identifier for the store or the store definition. | ||
- _storeNameOrDefinition_ `string|WPDataStore`: Unique namespace identifier for the store or the store definition. | ||
@@ -596,2 +596,25 @@ _Returns_ | ||
<a name="resolveSelect" href="#resolveSelect">#</a> **resolveSelect** | ||
Given the name of a registered store, returns an object containing the store's | ||
selectors pre-bound to state so that you only need to supply additional arguments, | ||
and modified so that they return promises that resolve to their eventual values, | ||
after any resolvers have ran. | ||
_Usage_ | ||
```js | ||
import { resolveSelect } from '@wordpress/data'; | ||
resolveSelect( 'my-shop' ).getPrice( 'hammer' ).then(console.log) | ||
``` | ||
_Parameters_ | ||
- _storeNameOrDefinition_ `string|WPDataStore`: Unique namespace identifier for the store or the store definition. | ||
_Returns_ | ||
- `Object`: Object containing the store's promise-wrapped selectors. | ||
<a name="select" href="#select">#</a> **select** | ||
@@ -613,3 +636,3 @@ | ||
- _storeNameOrDefinition_ `(string|WPDataStore)`: Unique namespace identifier for the store or the store definition. | ||
- _storeNameOrDefinition_ `string|WPDataStore`: Unique namespace identifier for the store or the store definition. | ||
@@ -695,3 +718,3 @@ _Returns_ | ||
- _storeNameOrDefinition_ `[(string|WPDataStore)]`: Optionally provide the name of the store or its definition from which to retrieve action creators. If not provided, the registry.dispatch function is returned instead. | ||
- _storeNameOrDefinition_ `[string|WPDataStore]`: Optionally provide the name of the store or its definition from which to retrieve action creators. If not provided, the registry.dispatch function is returned instead. | ||
@@ -698,0 +721,0 @@ _Returns_ |
@@ -100,3 +100,3 @@ /** | ||
.hasResolver | ||
? '__experimentalResolveSelect' | ||
? 'resolveSelect' | ||
: 'select'; | ||
@@ -103,0 +103,0 @@ return registry[ method ]( storeKey )[ selectorName ]( ...args ); |
@@ -109,5 +109,5 @@ /** | ||
* ```js | ||
* import { __experimentalResolveSelect } from '@wordpress/data'; | ||
* import { resolveSelect } from '@wordpress/data'; | ||
* | ||
* __experimentalResolveSelect( 'my-shop' ).getPrice( 'hammer' ).then(console.log) | ||
* resolveSelect( 'my-shop' ).getPrice( 'hammer' ).then(console.log) | ||
* ``` | ||
@@ -117,4 +117,3 @@ * | ||
*/ | ||
export const __experimentalResolveSelect = | ||
defaultRegistry.__experimentalResolveSelect; | ||
export const resolveSelect = defaultRegistry.resolveSelect; | ||
@@ -121,0 +120,0 @@ /** |
@@ -151,6 +151,7 @@ /** | ||
const resolveSelectors = mapResolveSelectors( selectors, store ); | ||
const getSelectors = () => selectors; | ||
const getActions = () => actions; | ||
const getResolveSelectors = () => | ||
mapResolveSelectors( selectors, store ); | ||
const getResolveSelectors = () => resolveSelectors; | ||
@@ -189,3 +190,3 @@ // We have some modules monkey-patching the store object | ||
getSelectors, | ||
__experimentalGetResolveSelectors: getResolveSelectors, | ||
getResolveSelectors, | ||
getActions, | ||
@@ -192,0 +193,0 @@ subscribe, |
@@ -115,3 +115,3 @@ /** | ||
*/ | ||
function __experimentalResolveSelect( storeNameOrDefinition ) { | ||
function resolveSelect( storeNameOrDefinition ) { | ||
const storeName = isObject( storeNameOrDefinition ) | ||
@@ -123,6 +123,6 @@ ? storeNameOrDefinition.name | ||
if ( store ) { | ||
return store.__experimentalGetResolveSelectors(); | ||
return store.getResolveSelectors(); | ||
} | ||
return parent && parent.__experimentalResolveSelect( storeName ); | ||
return parent && parent.resolveSelect( storeName ); | ||
} | ||
@@ -223,3 +223,3 @@ | ||
select, | ||
__experimentalResolveSelect, | ||
resolveSelect, | ||
dispatch, | ||
@@ -226,0 +226,0 @@ use, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
688489
183
10774
949