react-redux-cache 0.19.4-rc.0 → 0.19.5
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/README.md +1 -1
- package/dist/cjs/createCache.js +1 -0
- package/dist/cjs/query.js +6 -0
- package/dist/cjs/useQuery.js +1 -1
- package/dist/esm/createCache.js +1 -0
- package/dist/esm/query.js +6 -0
- package/dist/esm/useQuery.js +1 -0
- package/dist/types/query.d.ts +1 -0
- package/dist/types/types.d.ts +11 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Can be considered as `ApolloClient` for protocols other than `GraphQL`, but with
|
|
|
23
23
|
|Not overengineered|Simplicity is the main goal.|
|
|
24
24
|
|Performance|Every function is heavily optimized, Immer is not used ([RTK [Query] issue](https://github.com/reduxjs/redux-toolkit/issues/4793)).|
|
|
25
25
|
|Reliability|High test coverage, zero issue policy.|
|
|
26
|
-
|Lightweight|`npx minified-size dist/esm/*.js`<br/>minified: 18.
|
|
26
|
+
|Lightweight|`npx minified-size dist/esm/*.js`<br/>minified: 18.4 kB<br/>gzipped: 7.93 kB<br/>brotlied: 7.04 kB|
|
|
27
27
|
|
|
28
28
|
|Feature|Description|
|
|
29
29
|
|--|--|
|
package/dist/cjs/createCache.js
CHANGED
package/dist/cjs/query.js
CHANGED
|
@@ -45,6 +45,7 @@ const query = (
|
|
|
45
45
|
params,
|
|
46
46
|
secondsToLive,
|
|
47
47
|
onlyIfExpired,
|
|
48
|
+
skipFetch,
|
|
48
49
|
mergeResults,
|
|
49
50
|
onCompleted,
|
|
50
51
|
onSuccess,
|
|
@@ -73,6 +74,11 @@ const query = (
|
|
|
73
74
|
const {selectQueryResult, selectQueryState} = selectors
|
|
74
75
|
const logsEnabled = cache.options.logsEnabled
|
|
75
76
|
const queryStateOnStart = selectQueryState(store.getState(), queryKey, cacheKey)
|
|
77
|
+
if (skipFetch) {
|
|
78
|
+
return {
|
|
79
|
+
result: queryStateOnStart.result,
|
|
80
|
+
}
|
|
81
|
+
}
|
|
76
82
|
if (queryStateOnStart === null || queryStateOnStart === void 0 ? void 0 : queryStateOnStart.loading) {
|
|
77
83
|
logsEnabled &&
|
|
78
84
|
(0, utilsAndConstants_1.log)(`${logTag} fetch cancelled: already loading`, {
|
package/dist/cjs/useQuery.js
CHANGED
|
@@ -75,7 +75,7 @@ const useQuery = (cache, actions, selectors, options) => {
|
|
|
75
75
|
__awaiter(void 0, void 0, void 0, function* () {
|
|
76
76
|
const paramsPassed = options && 'params' in options
|
|
77
77
|
return yield (0,
|
|
78
|
-
query_1.query)('useQuery.fetch', store, cache, actions, selectors, queryKey, paramsPassed ? getCacheKey(options.params) : cacheKey, paramsPassed ? options.params : params, secondsToLive, options === null || options === void 0 ? void 0 : options.onlyIfExpired, mergeResults, onCompleted, onSuccess, onError)
|
|
78
|
+
query_1.query)('useQuery.fetch', store, cache, actions, selectors, queryKey, paramsPassed ? getCacheKey(options.params) : cacheKey, paramsPassed ? options.params : params, secondsToLive, options === null || options === void 0 ? void 0 : options.onlyIfExpired, false, mergeResults, onCompleted, onSuccess, onError)
|
|
79
79
|
}),
|
|
80
80
|
[store, queryKey, cacheKey]
|
|
81
81
|
)
|
package/dist/esm/createCache.js
CHANGED
package/dist/esm/query.js
CHANGED
|
@@ -42,6 +42,7 @@ export const query = (
|
|
|
42
42
|
params,
|
|
43
43
|
secondsToLive,
|
|
44
44
|
onlyIfExpired,
|
|
45
|
+
skipFetch,
|
|
45
46
|
mergeResults,
|
|
46
47
|
onCompleted,
|
|
47
48
|
onSuccess,
|
|
@@ -70,6 +71,11 @@ export const query = (
|
|
|
70
71
|
const {selectQueryResult, selectQueryState} = selectors
|
|
71
72
|
const logsEnabled = cache.options.logsEnabled
|
|
72
73
|
const queryStateOnStart = selectQueryState(store.getState(), queryKey, cacheKey)
|
|
74
|
+
if (skipFetch) {
|
|
75
|
+
return {
|
|
76
|
+
result: queryStateOnStart.result,
|
|
77
|
+
}
|
|
78
|
+
}
|
|
73
79
|
if (queryStateOnStart === null || queryStateOnStart === void 0 ? void 0 : queryStateOnStart.loading) {
|
|
74
80
|
logsEnabled &&
|
|
75
81
|
log(`${logTag} fetch cancelled: already loading`, {
|
package/dist/esm/useQuery.js
CHANGED
package/dist/types/query.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare const query: <
|
|
|
21
21
|
params: QK extends keyof (QP | QR) ? QP[QK] : never,
|
|
22
22
|
secondsToLive: number | undefined,
|
|
23
23
|
onlyIfExpired: boolean | undefined,
|
|
24
|
+
skipFetch: boolean | undefined,
|
|
24
25
|
mergeResults?:
|
|
25
26
|
| ((
|
|
26
27
|
oldResult: QR[keyof QP & keyof QR & string] | undefined,
|
package/dist/types/types.d.ts
CHANGED
|
@@ -236,7 +236,17 @@ export type QueryOptions<
|
|
|
236
236
|
QK extends keyof (QP & QR),
|
|
237
237
|
MP,
|
|
238
238
|
MR
|
|
239
|
-
> =
|
|
239
|
+
> = Pick<
|
|
240
|
+
UseQueryOptions<N, T, QK, QP, QR, MP, MR>,
|
|
241
|
+
| 'query'
|
|
242
|
+
| 'params'
|
|
243
|
+
| 'skipFetch'
|
|
244
|
+
| 'secondsToLive'
|
|
245
|
+
| 'mergeResults'
|
|
246
|
+
| 'onCompleted'
|
|
247
|
+
| 'onSuccess'
|
|
248
|
+
| 'onError'
|
|
249
|
+
> & {
|
|
240
250
|
/** If set to true, query will run only if it is expired or result not yet cached. */
|
|
241
251
|
onlyIfExpired?: boolean
|
|
242
252
|
}
|
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.19.
|
|
5
|
+
"version": "0.19.5",
|
|
6
6
|
"description": "Powerful data fetching and caching library for Redux and Zustand that supports normalization.",
|
|
7
7
|
"main": "./dist/cjs/index.js",
|
|
8
8
|
"module": "./dist/esm/index.js",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"preminor-rc": "yarn build && npm version preminor --preid rc",
|
|
30
30
|
"prepatch-rc": "yarn build && npm version prepatch --preid rc",
|
|
31
31
|
"publish-rc": "npm publish --tag rc",
|
|
32
|
+
"remove-rc": "npm version <same-version-without-rc>",
|
|
32
33
|
"prepublishOnly": "yarn build && yarn test"
|
|
33
34
|
},
|
|
34
35
|
"peerDependencies": {
|