react-redux-cache 0.18.2 → 0.18.4
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.
- package/dist/createCacheReducer.js +24 -3
- package/dist/index.js +6 -5
- package/package.json +1 -1
|
@@ -48,15 +48,24 @@ const createCacheReducer = (actions, queryKeys, cacheOptions) => {
|
|
|
48
48
|
const oldQueryState = state.queries[queryKey][queryCacheKey];
|
|
49
49
|
let newQueryState = queryState && Object.assign(Object.assign({}, oldQueryState), queryState);
|
|
50
50
|
if (newQueryState) {
|
|
51
|
+
if (oldQueryState && deepEqual) {
|
|
52
|
+
// set back params if deeply same value
|
|
53
|
+
if (newQueryState.params !== oldQueryState.params &&
|
|
54
|
+
deepEqual(newQueryState.params, oldQueryState.params)) {
|
|
55
|
+
newQueryState.params = oldQueryState.params;
|
|
56
|
+
}
|
|
57
|
+
// set back if deeply same value
|
|
58
|
+
if (newQueryState.result !== oldQueryState.result &&
|
|
59
|
+
deepEqual(newQueryState.result, oldQueryState.result)) {
|
|
60
|
+
newQueryState.result = oldQueryState.result;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
51
63
|
// remove undefined optional fields
|
|
52
64
|
for (const key of optionalQueryKeys) {
|
|
53
65
|
if (key in newQueryState && newQueryState[key] === undefined) {
|
|
54
66
|
delete newQueryState[key];
|
|
55
67
|
}
|
|
56
68
|
}
|
|
57
|
-
if ('loading' in newQueryState && !newQueryState.loading) {
|
|
58
|
-
delete newQueryState.loading;
|
|
59
|
-
}
|
|
60
69
|
// skip if new state deep equals to the old state
|
|
61
70
|
if (deepEqual === null || deepEqual === void 0 ? void 0 : deepEqual(oldQueryState !== null && oldQueryState !== void 0 ? oldQueryState : utilsAndConstants_1.EMPTY_OBJECT, newQueryState)) {
|
|
62
71
|
newQueryState = undefined;
|
|
@@ -87,6 +96,18 @@ const createCacheReducer = (actions, queryKeys, cacheOptions) => {
|
|
|
87
96
|
const oldMutationState = state.mutations[mutationKey];
|
|
88
97
|
let newMutationState = mutationState && Object.assign(Object.assign({}, oldMutationState), mutationState);
|
|
89
98
|
if (newMutationState) {
|
|
99
|
+
if (oldMutationState && deepEqual) {
|
|
100
|
+
// set back params if deeply same value
|
|
101
|
+
if (newMutationState.params !== oldMutationState.params &&
|
|
102
|
+
deepEqual(newMutationState.params, oldMutationState.params)) {
|
|
103
|
+
newMutationState.params = oldMutationState.params;
|
|
104
|
+
}
|
|
105
|
+
// set back if deeply same value
|
|
106
|
+
if (newMutationState.result !== oldMutationState.result &&
|
|
107
|
+
deepEqual(newMutationState.result, oldMutationState.result)) {
|
|
108
|
+
newMutationState.result = oldMutationState.result;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
90
111
|
// remove optional fields with default values
|
|
91
112
|
for (const key of optionalMutationKeys) {
|
|
92
113
|
if (key in newMutationState && newMutationState[key] === undefined) {
|
package/dist/index.js
CHANGED
|
@@ -26,13 +26,10 @@ Object.defineProperty(exports, "defaultGetCacheKey", { enumerable: true, get: fu
|
|
|
26
26
|
Object.defineProperty(exports, "FetchPolicy", { enumerable: true, get: function () { return utilsAndConstants_1.FetchPolicy; } });
|
|
27
27
|
Object.defineProperty(exports, "isEmptyObject", { enumerable: true, get: function () { return utilsAndConstants_1.isEmptyObject; } });
|
|
28
28
|
// Backlog
|
|
29
|
-
// highest
|
|
30
|
-
// generate full api docs
|
|
31
|
-
// cancel all queries / mutations
|
|
32
|
-
// selectors optional cache key
|
|
33
29
|
// ! high (1.0.0-rc.0)
|
|
30
|
+
// generate full api docs
|
|
34
31
|
// optimistic response
|
|
35
|
-
// features list
|
|
32
|
+
// features list (table)
|
|
36
33
|
// ! medium
|
|
37
34
|
// onCancel & onAbort
|
|
38
35
|
// remove empty entities and queries from state
|
|
@@ -51,3 +48,7 @@ Object.defineProperty(exports, "isEmptyObject", { enumerable: true, get: functio
|
|
|
51
48
|
// readonly types?
|
|
52
49
|
// proper types, remove as, any, todo
|
|
53
50
|
// add number of retries param?
|
|
51
|
+
// mutation state wrong type - can be undefined?
|
|
52
|
+
// ! on hold
|
|
53
|
+
// better support queries without params: useQuery & selectors optional cache key (making useQuery params optional doesn't seem like a good idea)
|
|
54
|
+
// cancel all queries / mutations (already possible by recreating the store - this lib is pure)
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "react-redux-cache",
|
|
3
3
|
"author": "Alexander Danilov",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.18.
|
|
5
|
+
"version": "0.18.4",
|
|
6
6
|
"description": "Powerful data fetching and caching library for Redux and Zustand that supports normalization.",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|