@wordpress/data 10.12.0 → 10.13.1-next.082ed6819.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +16 -21
  3. package/package.json +9 -9
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 10.13.0-next.0 (2024-11-26)
6
+
7
+ ### Enhancements
8
+
9
+ - Upgrade `redux` dependency to `^5.0.1` ([#66966](https://github.com/WordPress/gutenberg/pull/66966))
10
+
5
11
  ## 10.12.0 (2024-11-16)
6
12
 
7
13
  ## 10.11.0 (2024-10-30)
package/README.md CHANGED
@@ -42,13 +42,6 @@ const actions = {
42
42
  discountPercent,
43
43
  };
44
44
  },
45
-
46
- fetchFromAPI( path ) {
47
- return {
48
- type: 'FETCH_FROM_API',
49
- path,
50
- };
51
- },
52
45
  };
53
46
 
54
47
  const store = createReduxStore( 'my-shop', {
@@ -84,17 +77,11 @@ const store = createReduxStore( 'my-shop', {
84
77
  },
85
78
  },
86
79
 
87
- controls: {
88
- FETCH_FROM_API( action ) {
89
- return apiFetch( { path: action.path } );
90
- },
91
- },
92
-
93
80
  resolvers: {
94
- *getPrice( item ) {
81
+ getPrice: ( item ) => async ({ dispatch }) => { {
95
82
  const path = '/wp/v2/prices/' + item;
96
- const price = yield actions.fetchFromAPI( path );
97
- return actions.setPrice( item, price );
83
+ const price = await apiFetch( { path } );
84
+ dispatch.setPrice( item, price );
98
85
  },
99
86
  },
100
87
  } );
@@ -133,13 +120,21 @@ A **resolver** is a side-effect for a selector. If your selector result may need
133
120
 
134
121
  The `resolvers` option should be passed as an object where each key is the name of the selector to act upon, the value a function which receives the same arguments passed to the selector, excluding the state argument. It can then dispatch as necessary to fulfill the requirements of the selector, taking advantage of the fact that most data consumers will subscribe to subsequent state changes (by `subscribe` or `withSelect`).
135
122
 
136
- #### `controls`
123
+ Resolvers, in combination with [thunks](https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/thunks.md#thunks-can-be-async), can be used to implement asynchronous data flows for your store.
137
124
 
138
- A **control** defines the execution flow behavior associated with a specific action type. This can be particularly useful in implementing asynchronous data flows for your store. By defining your action creator or resolvers as a generator which yields specific controlled action types, the execution will proceed as defined by the control handler.
125
+ #### `controls` (deprecated)
139
126
 
140
- The `controls` option should be passed as an object where each key is the name of the action type to act upon, the value a function which receives the original action object. It should returns either a promise which is to resolve when evaluation of the action should continue, or a value. The value or resolved promise value is assigned on the return value of the yield assignment. If the control handler returns undefined, the execution is not continued.
127
+ To handle asynchronous data flows, it is recommended to use [thunks](https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/thunks.md#thunks-can-be-async) instead of `controls`.
141
128
 
142
- Refer to the [documentation of `@wordpress/redux-routine`](https://github.com/WordPress/gutenberg/tree/HEAD/packages/redux-routine/README.md) for more information.
129
+ <details>
130
+ <summary>View <em>controls</em> explanation</summary>
131
+ <br>
132
+ A <em>control</em> defines the execution flow behavior associated with a specific action type. Before <a href="https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/thunks.md#thunks-can-be-async">thunks</a>, controls were used to implement asynchronous data flows for your store. By defining your action creator or resolvers as a generator which yields specific controlled action types, the execution will proceed as defined by the control handler.
133
+ <br><br>
134
+ The <em>controls</em> option should be passed as an object where each key is the name of the action type to act upon, the value a function which receives the original action object. It should returns either a promise which is to resolve when evaluation of the action should continue, or a value. The value or resolved promise value is assigned on the return value of the yield assignment. If the control handler returns undefined, the execution is not continued.
135
+ <br><br>
136
+ Refer to the <a href="https://github.com/WordPress/gutenberg/tree/HEAD/packages/redux-routine/README.md">documentation of <em>@wordpress/redux-routine</em></a> for more information.
137
+ </details>
143
138
 
144
139
  #### `initialState`
145
140
 
@@ -262,7 +257,7 @@ The data module shares many of the same [core principles](https://redux.js.org/i
262
257
 
263
258
  The [higher-order components](#higher-order-components) were created to complement this distinction. The intention with splitting `withSelect` and `withDispatch` — where in React Redux they are combined under `connect` as `mapStateToProps` and `mapDispatchToProps` arguments — is to more accurately reflect that dispatch is not dependent upon a subscription to state changes, and to allow for state-derived values to be used in `withDispatch` (via [higher-order component composition](https://github.com/WordPress/gutenberg/tree/HEAD/packages/compose/README.md)).
264
259
 
265
- The data module also has built-in solutions for handling asynchronous side-effects, through [resolvers](#resolvers) and [controls](#controls). These differ slightly from [standard redux async solutions](https://redux.js.org/advanced/async-actions) like [`redux-thunk`](https://github.com/gaearon/redux-thunk) or [`redux-saga`](https://redux-saga.js.org/).
260
+ The data module also has built-in solutions for handling asynchronous side-effects, through [resolvers](#resolvers) and [thunks](https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/thunks.md#thunks-can-be-async). These differ slightly from [standard redux async solutions](https://redux.js.org/advanced/async-actions) like [`redux-thunk`](https://github.com/gaearon/redux-thunk) or [`redux-saga`](https://redux-saga.js.org/).
266
261
 
267
262
  Specific implementation differences from Redux and React Redux:
268
263
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/data",
3
- "version": "10.12.0",
3
+ "version": "10.13.1-next.082ed6819.0",
4
4
  "description": "Data module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -31,13 +31,13 @@
31
31
  "sideEffects": false,
32
32
  "dependencies": {
33
33
  "@babel/runtime": "7.25.7",
34
- "@wordpress/compose": "*",
35
- "@wordpress/deprecated": "*",
36
- "@wordpress/element": "*",
37
- "@wordpress/is-shallow-equal": "*",
38
- "@wordpress/priority-queue": "*",
39
- "@wordpress/private-apis": "*",
40
- "@wordpress/redux-routine": "*",
34
+ "@wordpress/compose": "^7.12.1-next.082ed6819.0",
35
+ "@wordpress/deprecated": "^4.12.1-next.082ed6819.0",
36
+ "@wordpress/element": "^6.12.1-next.082ed6819.0",
37
+ "@wordpress/is-shallow-equal": "^5.12.1-next.082ed6819.0",
38
+ "@wordpress/priority-queue": "^3.12.1-next.082ed6819.0",
39
+ "@wordpress/private-apis": "^1.12.1-next.082ed6819.0",
40
+ "@wordpress/redux-routine": "^5.12.1-next.082ed6819.0",
41
41
  "deepmerge": "^4.3.0",
42
42
  "equivalent-key-map": "^0.2.2",
43
43
  "is-plain-object": "^5.0.0",
@@ -52,5 +52,5 @@
52
52
  "publishConfig": {
53
53
  "access": "public"
54
54
  },
55
- "gitHead": "510540d99f3d222a96f08d3d7b66c9e7a726f705"
55
+ "gitHead": "2bb7bad15ddb8e88210fab7d4a1ef1565466e424"
56
56
  }