react-redux-cache 0.22.1 → 0.22.2
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 +2 -2
- package/dist/cjs/createActions.js +63 -63
- package/dist/cjs/createCache.js +216 -131
- package/dist/cjs/createReducer.js +355 -290
- package/dist/cjs/createSelectors.js +66 -58
- package/dist/cjs/index.js +87 -26
- package/dist/cjs/mutate.js +153 -70
- package/dist/cjs/query.js +161 -70
- package/dist/cjs/types.js +2 -2
- package/dist/cjs/useMutation.js +81 -42
- package/dist/cjs/useQuery.js +127 -56
- package/dist/cjs/utilsAndConstants.js +204 -151
- package/dist/esm/createActions.js +60 -59
- package/dist/esm/createCache.js +218 -127
- package/dist/esm/createReducer.js +349 -286
- package/dist/esm/createSelectors.js +63 -54
- package/dist/esm/index.js +3 -3
- package/dist/esm/mutate.js +143 -66
- package/dist/esm/query.js +149 -66
- package/dist/esm/types.js +1 -1
- package/dist/esm/useMutation.js +77 -38
- package/dist/esm/useQuery.js +119 -52
- package/dist/esm/utilsAndConstants.js +190 -140
- package/dist/types/createActions.d.ts +109 -83
- package/dist/types/createCache.d.ts +734 -409
- package/dist/types/createReducer.d.ts +11 -3
- package/dist/types/createSelectors.d.ts +80 -18
- package/dist/types/index.d.ts +3 -3
- package/dist/types/mutate.d.ts +94 -4
- package/dist/types/query.d.ts +123 -4
- package/dist/types/types.d.ts +360 -184
- package/dist/types/useMutation.d.ts +39 -4
- package/dist/types/useQuery.d.ts +40 -4
- package/dist/types/utilsAndConstants.d.ts +56 -23
- package/package.json +4 -5
|
@@ -1,55 +1,64 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {EMPTY_OBJECT} from './utilsAndConstants'
|
|
2
|
+
|
|
2
3
|
export const createSelectors = (cache) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
4
|
+
const selectEntityById = (state, id, typename) => {
|
|
5
|
+
var _a
|
|
6
|
+
return id == null
|
|
7
|
+
? undefined
|
|
8
|
+
: (_a = cache.cacheStateSelector(state).entities[typename]) === null || _a === void 0
|
|
9
|
+
? void 0
|
|
10
|
+
: _a[id]
|
|
11
|
+
}
|
|
12
|
+
const selectQueryState = (state, query, cacheKey) => {
|
|
13
|
+
var _a
|
|
14
|
+
return (_a = cache.cacheStateSelector(state).queries[query][cacheKey]) !== null && _a !== void 0
|
|
15
|
+
? _a
|
|
16
|
+
: EMPTY_OBJECT
|
|
17
|
+
}
|
|
18
|
+
const selectMutationState = (state, mutation) => {
|
|
19
|
+
var _a
|
|
20
|
+
return (_a = cache.cacheStateSelector(state).mutations[mutation]) !== null && _a !== void 0
|
|
21
|
+
? _a
|
|
22
|
+
: EMPTY_OBJECT
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
selectEntityById,
|
|
26
|
+
selectQueryState,
|
|
27
|
+
selectQueryResult: (state, query, cacheKey) => {
|
|
28
|
+
return selectQueryState(state, query, cacheKey).result
|
|
29
|
+
},
|
|
30
|
+
selectQueryLoading: (state, query, cacheKey) => {
|
|
31
|
+
var _a
|
|
32
|
+
return (_a = selectQueryState(state, query, cacheKey).loading) !== null && _a !== void 0 ? _a : false
|
|
33
|
+
},
|
|
34
|
+
selectQueryError: (state, query, cacheKey) => {
|
|
35
|
+
return selectQueryState(state, query, cacheKey).error
|
|
36
|
+
},
|
|
37
|
+
selectQueryParams: (state, query, cacheKey) => {
|
|
38
|
+
return selectQueryState(state, query, cacheKey).params
|
|
39
|
+
},
|
|
40
|
+
selectQueryExpiresAt: (state, query, cacheKey) => {
|
|
41
|
+
return selectQueryState(state, query, cacheKey).expiresAt
|
|
42
|
+
},
|
|
43
|
+
selectMutationState,
|
|
44
|
+
selectMutationResult: (state, mutation) => {
|
|
45
|
+
return selectMutationState(state, mutation).result
|
|
46
|
+
},
|
|
47
|
+
selectMutationLoading: (state, mutation) => {
|
|
48
|
+
var _a
|
|
49
|
+
return (_a = selectMutationState(state, mutation).loading) !== null && _a !== void 0 ? _a : false
|
|
50
|
+
},
|
|
51
|
+
selectMutationError: (state, mutation) => {
|
|
52
|
+
return selectMutationState(state, mutation).error
|
|
53
|
+
},
|
|
54
|
+
selectMutationParams: (state, mutation) => {
|
|
55
|
+
return selectMutationState(state, mutation).params
|
|
56
|
+
},
|
|
57
|
+
selectEntities: (state) => {
|
|
58
|
+
return cache.cacheStateSelector(state).entities
|
|
59
|
+
},
|
|
60
|
+
selectEntitiesByTypename: (state, typename) => {
|
|
61
|
+
return cache.cacheStateSelector(state).entities[typename]
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export * from './types'
|
|
3
|
-
export {
|
|
1
|
+
export {createCache, withTypenames} from './createCache'
|
|
2
|
+
export * from './types'
|
|
3
|
+
export {createStateComparer, defaultGetCacheKey, FetchPolicy, isEmptyObject, noop} from './utilsAndConstants'
|
package/dist/esm/mutate.js
CHANGED
|
@@ -1,73 +1,150 @@
|
|
|
1
|
-
var __awaiter =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
import { logDebug } from './utilsAndConstants';
|
|
11
|
-
export const mutate = (logTag_1, store_1, cache_1, actions_1, selectors_1, mutationKey_1, params_1, abortControllers_1, ...args_1) => __awaiter(void 0, [logTag_1, store_1, cache_1, actions_1, selectors_1, mutationKey_1, params_1, abortControllers_1, ...args_1], void 0, function* (logTag, store, cache, actions, selectors, mutationKey, params, abortControllers, onCompleted = cache.mutations[mutationKey].onCompleted, onSuccess = cache.mutations[mutationKey].onSuccess, onError = cache.mutations[mutationKey].onError) {
|
|
12
|
-
var _a, _b;
|
|
13
|
-
const { updateMutationStateAndEntities } = actions;
|
|
14
|
-
let abortControllersOfStore = abortControllers.get(store);
|
|
15
|
-
if (abortControllersOfStore === undefined) {
|
|
16
|
-
abortControllersOfStore = {};
|
|
17
|
-
abortControllers.set(store, abortControllersOfStore);
|
|
1
|
+
var __awaiter =
|
|
2
|
+
(this && this.__awaiter) ||
|
|
3
|
+
function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) {
|
|
5
|
+
return value instanceof P
|
|
6
|
+
? value
|
|
7
|
+
: new P(function (resolve) {
|
|
8
|
+
resolve(value)
|
|
9
|
+
})
|
|
18
10
|
}
|
|
19
|
-
{
|
|
20
|
-
|
|
11
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
12
|
+
function fulfilled(value) {
|
|
13
|
+
try {
|
|
14
|
+
step(generator.next(value))
|
|
15
|
+
} catch (e) {
|
|
16
|
+
reject(e)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function rejected(value) {
|
|
20
|
+
try {
|
|
21
|
+
step(generator['throw'](value))
|
|
22
|
+
} catch (e) {
|
|
23
|
+
reject(e)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function step(result) {
|
|
27
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected)
|
|
28
|
+
}
|
|
29
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next())
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
import {logDebug} from './utilsAndConstants'
|
|
33
|
+
|
|
34
|
+
export const mutate = (
|
|
35
|
+
logTag_1,
|
|
36
|
+
store_1,
|
|
37
|
+
cache_1,
|
|
38
|
+
actions_1,
|
|
39
|
+
selectors_1,
|
|
40
|
+
mutationKey_1,
|
|
41
|
+
params_1,
|
|
42
|
+
abortControllers_1,
|
|
43
|
+
...args_1
|
|
44
|
+
) =>
|
|
45
|
+
__awaiter(
|
|
46
|
+
void 0,
|
|
47
|
+
[
|
|
48
|
+
logTag_1,
|
|
49
|
+
store_1,
|
|
50
|
+
cache_1,
|
|
51
|
+
actions_1,
|
|
52
|
+
selectors_1,
|
|
53
|
+
mutationKey_1,
|
|
54
|
+
params_1,
|
|
55
|
+
abortControllers_1,
|
|
56
|
+
...args_1,
|
|
57
|
+
],
|
|
58
|
+
void 0,
|
|
59
|
+
function* (
|
|
60
|
+
logTag,
|
|
61
|
+
store,
|
|
62
|
+
cache,
|
|
63
|
+
actions,
|
|
64
|
+
selectors,
|
|
65
|
+
mutationKey,
|
|
66
|
+
params,
|
|
67
|
+
abortControllers,
|
|
68
|
+
onCompleted = cache.mutations[mutationKey].onCompleted,
|
|
69
|
+
onSuccess = cache.mutations[mutationKey].onSuccess,
|
|
70
|
+
onError = cache.mutations[mutationKey].onError,
|
|
71
|
+
) {
|
|
72
|
+
var _a, _b
|
|
73
|
+
const {updateMutationStateAndEntities} = actions
|
|
74
|
+
let abortControllersOfStore = abortControllers.get(store)
|
|
75
|
+
if (abortControllersOfStore === undefined) {
|
|
76
|
+
abortControllersOfStore = {}
|
|
77
|
+
abortControllers.set(store, abortControllersOfStore)
|
|
78
|
+
}
|
|
79
|
+
{
|
|
80
|
+
const abortController = abortControllersOfStore[mutationKey]
|
|
21
81
|
cache.options.logsEnabled &&
|
|
22
|
-
|
|
82
|
+
logDebug(logTag, {mutationKey, params, previousAborted: abortController !== undefined})
|
|
23
83
|
if (abortController !== undefined) {
|
|
24
|
-
|
|
84
|
+
abortController.abort()
|
|
25
85
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
86
|
+
}
|
|
87
|
+
const abortController = new AbortController()
|
|
88
|
+
abortControllersOfStore[mutationKey] = abortController
|
|
89
|
+
const mutatePromise = cache.mutations[mutationKey].mutation(params, store, abortController.signal)
|
|
90
|
+
store.dispatch(
|
|
91
|
+
updateMutationStateAndEntities(mutationKey, {
|
|
92
|
+
loading: mutatePromise,
|
|
93
|
+
params,
|
|
94
|
+
result: undefined,
|
|
95
|
+
}),
|
|
96
|
+
)
|
|
97
|
+
let response
|
|
98
|
+
let error
|
|
99
|
+
try {
|
|
100
|
+
response = yield mutatePromise
|
|
101
|
+
} catch (e) {
|
|
102
|
+
error = e
|
|
103
|
+
}
|
|
104
|
+
cache.options.logsEnabled &&
|
|
105
|
+
logDebug(`${logTag} finished`, {response, error, aborted: abortController.signal.aborted})
|
|
106
|
+
if (abortController.signal.aborted) {
|
|
107
|
+
return ABORTED_RESULT
|
|
108
|
+
}
|
|
109
|
+
delete abortControllersOfStore[mutationKey]
|
|
110
|
+
if (error) {
|
|
111
|
+
store.dispatch(
|
|
112
|
+
updateMutationStateAndEntities(mutationKey, {
|
|
113
|
+
error,
|
|
52
114
|
loading: undefined,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
115
|
+
}),
|
|
116
|
+
)
|
|
117
|
+
if (
|
|
118
|
+
!(onError === null || onError === void 0
|
|
119
|
+
? void 0
|
|
120
|
+
: onError(error, params, store, actions, selectors))
|
|
121
|
+
) {
|
|
122
|
+
;(_b = (_a = cache.globals).onError) === null || _b === void 0
|
|
123
|
+
? void 0
|
|
124
|
+
: _b.call(_a, error, mutationKey, params, store, actions, selectors)
|
|
56
125
|
}
|
|
57
|
-
onCompleted === null || onCompleted === void 0
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
126
|
+
onCompleted === null || onCompleted === void 0
|
|
127
|
+
? void 0
|
|
128
|
+
: onCompleted(response, error, params, store, actions, selectors)
|
|
129
|
+
return {error}
|
|
130
|
+
}
|
|
131
|
+
if (response) {
|
|
61
132
|
const newState = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
store.dispatch(updateMutationStateAndEntities(mutationKey, newState, response))
|
|
67
|
-
onSuccess === null || onSuccess === void 0
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
133
|
+
error: undefined,
|
|
134
|
+
loading: undefined,
|
|
135
|
+
result: response.result,
|
|
136
|
+
}
|
|
137
|
+
store.dispatch(updateMutationStateAndEntities(mutationKey, newState, response))
|
|
138
|
+
onSuccess === null || onSuccess === void 0
|
|
139
|
+
? void 0
|
|
140
|
+
: onSuccess(response, params, store, actions, selectors)
|
|
141
|
+
onCompleted === null || onCompleted === void 0
|
|
142
|
+
? void 0
|
|
143
|
+
: onCompleted(response, error, params, store, actions, selectors)
|
|
144
|
+
return {result: response.result}
|
|
145
|
+
}
|
|
146
|
+
throw new Error(`${logTag}: both error and response are not defined`)
|
|
147
|
+
},
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
const ABORTED_RESULT = Object.freeze({aborted: true})
|
package/dist/esm/query.js
CHANGED
|
@@ -1,77 +1,160 @@
|
|
|
1
|
-
var __awaiter =
|
|
2
|
-
|
|
1
|
+
var __awaiter =
|
|
2
|
+
(this && this.__awaiter) ||
|
|
3
|
+
function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) {
|
|
5
|
+
return value instanceof P
|
|
6
|
+
? value
|
|
7
|
+
: new P(function (resolve) {
|
|
8
|
+
resolve(value)
|
|
9
|
+
})
|
|
10
|
+
}
|
|
3
11
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
function fulfilled(value) {
|
|
13
|
+
try {
|
|
14
|
+
step(generator.next(value))
|
|
15
|
+
} catch (e) {
|
|
16
|
+
reject(e)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function rejected(value) {
|
|
20
|
+
try {
|
|
21
|
+
step(generator['throw'](value))
|
|
22
|
+
} catch (e) {
|
|
23
|
+
reject(e)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function step(result) {
|
|
27
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected)
|
|
28
|
+
}
|
|
29
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next())
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
import {logDebug, noop} from './utilsAndConstants'
|
|
33
|
+
|
|
34
|
+
export const query = (
|
|
35
|
+
logTag,
|
|
36
|
+
store,
|
|
37
|
+
cache,
|
|
38
|
+
actions,
|
|
39
|
+
selectors,
|
|
40
|
+
queryKey,
|
|
41
|
+
cacheKey,
|
|
42
|
+
params,
|
|
43
|
+
secondsToLive,
|
|
44
|
+
onlyIfExpired,
|
|
45
|
+
skipFetch,
|
|
46
|
+
mergeResults,
|
|
47
|
+
onCompleted,
|
|
48
|
+
onSuccess,
|
|
49
|
+
onError,
|
|
50
|
+
) =>
|
|
51
|
+
__awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
+
var _a, _b, _c, _d
|
|
53
|
+
if (secondsToLive === void 0) {
|
|
54
|
+
secondsToLive =
|
|
55
|
+
(_a = cache.queries[queryKey].secondsToLive) !== null && _a !== void 0
|
|
56
|
+
? _a
|
|
57
|
+
: cache.globals.queries.secondsToLive
|
|
58
|
+
}
|
|
59
|
+
if (mergeResults === void 0) {
|
|
60
|
+
mergeResults = cache.queries[queryKey].mergeResults
|
|
61
|
+
}
|
|
62
|
+
if (onCompleted === void 0) {
|
|
63
|
+
onCompleted = cache.queries[queryKey].onCompleted
|
|
64
|
+
}
|
|
65
|
+
if (onSuccess === void 0) {
|
|
66
|
+
onSuccess = cache.queries[queryKey].onSuccess
|
|
67
|
+
}
|
|
68
|
+
if (onError === void 0) {
|
|
69
|
+
onError = cache.queries[queryKey].onError
|
|
70
|
+
}
|
|
71
|
+
const {selectQueryResult, selectQueryState} = selectors
|
|
72
|
+
const logsEnabled = cache.options.logsEnabled
|
|
73
|
+
const queryStateOnStart = selectQueryState(store.getState(), queryKey, cacheKey)
|
|
21
74
|
if (skipFetch) {
|
|
22
|
-
|
|
75
|
+
return {result: queryStateOnStart.result}
|
|
23
76
|
}
|
|
24
77
|
if (queryStateOnStart === null || queryStateOnStart === void 0 ? void 0 : queryStateOnStart.loading) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
78
|
+
logsEnabled &&
|
|
79
|
+
logDebug(`${logTag} fetch cancelled: already loading`, {queryStateOnStart, params, cacheKey})
|
|
80
|
+
const error = yield queryStateOnStart.loading.then(noop).catch(catchAndReturn)
|
|
81
|
+
const result = selectQueryResult(store.getState(), queryKey, cacheKey)
|
|
82
|
+
const cancelled = 'loading'
|
|
83
|
+
return error ? {cancelled, result, error} : {cancelled, result}
|
|
31
84
|
}
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
85
|
+
if (
|
|
86
|
+
onlyIfExpired &&
|
|
87
|
+
(queryStateOnStart === null || queryStateOnStart === void 0 ? void 0 : queryStateOnStart.expiresAt) !=
|
|
88
|
+
null &&
|
|
89
|
+
queryStateOnStart.expiresAt > Date.now()
|
|
90
|
+
) {
|
|
91
|
+
logsEnabled &&
|
|
92
|
+
logDebug(`${logTag} fetch cancelled: not expired yet`, {
|
|
93
|
+
queryStateOnStart,
|
|
94
|
+
params,
|
|
95
|
+
cacheKey,
|
|
96
|
+
onlyIfExpired,
|
|
97
|
+
})
|
|
98
|
+
return {cancelled: 'not-expired', result: queryStateOnStart.result}
|
|
41
99
|
}
|
|
42
|
-
const {
|
|
43
|
-
const fetchPromise = cache.queries[queryKey].query(params, store)
|
|
44
|
-
store.dispatch(
|
|
100
|
+
const {updateQueryStateAndEntities} = actions
|
|
101
|
+
const fetchPromise = cache.queries[queryKey].query(params, store)
|
|
102
|
+
store.dispatch(
|
|
103
|
+
updateQueryStateAndEntities(queryKey, cacheKey, {
|
|
45
104
|
loading: fetchPromise,
|
|
46
105
|
params,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
106
|
+
}),
|
|
107
|
+
)
|
|
108
|
+
logsEnabled &&
|
|
109
|
+
logDebug(`${logTag} started`, {queryKey, params, cacheKey, queryStateOnStart, onlyIfExpired})
|
|
110
|
+
let response
|
|
50
111
|
try {
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
112
|
+
response = yield fetchPromise
|
|
113
|
+
} catch (error) {
|
|
114
|
+
store.dispatch(
|
|
115
|
+
updateQueryStateAndEntities(queryKey, cacheKey, {
|
|
116
|
+
error,
|
|
117
|
+
loading: undefined,
|
|
118
|
+
}),
|
|
119
|
+
)
|
|
120
|
+
if (!(onError === null || onError === void 0 ? void 0 : onError(error, params, store))) {
|
|
121
|
+
;(_c = (_b = cache.globals).onError) === null || _c === void 0
|
|
122
|
+
? void 0
|
|
123
|
+
: _c.call(_b, error, queryKey, params, store, actions, selectors)
|
|
124
|
+
}
|
|
125
|
+
onCompleted === null || onCompleted === void 0
|
|
126
|
+
? void 0
|
|
127
|
+
: onCompleted(undefined, error, params, store, actions, selectors)
|
|
128
|
+
return {error, result: selectQueryResult(store.getState(), queryKey, cacheKey)}
|
|
63
129
|
}
|
|
64
130
|
const newState = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
131
|
+
error: undefined,
|
|
132
|
+
loading: undefined,
|
|
133
|
+
expiresAt:
|
|
134
|
+
(_d = response.expiresAt) !== null && _d !== void 0
|
|
135
|
+
? _d
|
|
136
|
+
: secondsToLive != null
|
|
137
|
+
? Date.now() + secondsToLive * 1000
|
|
138
|
+
: undefined,
|
|
139
|
+
result: mergeResults
|
|
140
|
+
? mergeResults(
|
|
141
|
+
selectQueryResult(store.getState(), queryKey, cacheKey),
|
|
142
|
+
response,
|
|
143
|
+
params,
|
|
144
|
+
store,
|
|
145
|
+
actions,
|
|
146
|
+
selectors,
|
|
147
|
+
)
|
|
148
|
+
: response.result,
|
|
149
|
+
}
|
|
150
|
+
store.dispatch(updateQueryStateAndEntities(queryKey, cacheKey, newState, response))
|
|
151
|
+
onSuccess === null || onSuccess === void 0
|
|
152
|
+
? void 0
|
|
153
|
+
: onSuccess(response, params, store, actions, selectors)
|
|
154
|
+
onCompleted === null || onCompleted === void 0
|
|
155
|
+
? void 0
|
|
156
|
+
: onCompleted(response, undefined, params, store, actions, selectors)
|
|
157
|
+
return {result: newState === null || newState === void 0 ? void 0 : newState.result}
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
const catchAndReturn = (x) => x
|
package/dist/esm/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {}
|