@depup/reduxjs__toolkit 2.12.0-depup.29 → 2.13.0-depup.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.
- package/README.md +2 -2
- package/changes.json +1 -1
- package/dist/cjs/redux-toolkit.development.cjs +1755 -2247
- package/dist/cjs/redux-toolkit.development.cjs.map +1 -1
- package/dist/cjs/redux-toolkit.production.min.cjs +1 -2
- package/dist/cjs/redux-toolkit.production.min.cjs.map +1 -1
- package/dist/index.d.mts +1496 -1525
- package/dist/index.d.ts +1496 -1525
- package/dist/query/cjs/rtk-query.development.cjs +2059 -2990
- package/dist/query/cjs/rtk-query.development.cjs.map +1 -1
- package/dist/query/cjs/rtk-query.production.min.cjs +1 -1
- package/dist/query/cjs/rtk-query.production.min.cjs.map +1 -1
- package/dist/query/index.d.mts +2300 -2308
- package/dist/query/index.d.ts +2300 -2308
- package/dist/query/react/cjs/rtk-query-react.development.cjs +609 -714
- package/dist/query/react/cjs/rtk-query-react.development.cjs.map +1 -1
- package/dist/query/react/cjs/rtk-query-react.production.min.cjs +1 -1
- package/dist/query/react/cjs/rtk-query-react.production.min.cjs.map +1 -1
- package/dist/query/react/index.d.mts +516 -523
- package/dist/query/react/index.d.ts +516 -523
- package/dist/query/react/rtk-query-react.browser.mjs +1 -1
- package/dist/query/react/rtk-query-react.browser.mjs.map +1 -1
- package/dist/query/react/rtk-query-react.legacy-esm.js +672 -714
- package/dist/query/react/rtk-query-react.legacy-esm.js.map +1 -1
- package/dist/query/react/rtk-query-react.modern.mjs +586 -679
- package/dist/query/react/rtk-query-react.modern.mjs.map +1 -1
- package/dist/query/rtk-query.browser.mjs +1 -1
- package/dist/query/rtk-query.browser.mjs.map +1 -1
- package/dist/query/rtk-query.legacy-esm.js +2175 -3014
- package/dist/query/rtk-query.legacy-esm.js.map +1 -1
- package/dist/query/rtk-query.modern.mjs +2052 -2949
- package/dist/query/rtk-query.modern.mjs.map +1 -1
- package/dist/react/cjs/redux-toolkit-react.development.cjs +30 -51
- package/dist/react/cjs/redux-toolkit-react.development.cjs.map +1 -1
- package/dist/react/cjs/redux-toolkit-react.production.min.cjs +1 -1
- package/dist/react/cjs/redux-toolkit-react.production.min.cjs.map +1 -1
- package/dist/react/index.d.mts +12 -15
- package/dist/react/index.d.ts +12 -15
- package/dist/react/redux-toolkit-react.browser.mjs +1 -1
- package/dist/react/redux-toolkit-react.browser.mjs.map +1 -1
- package/dist/react/redux-toolkit-react.legacy-esm.js +83 -44
- package/dist/react/redux-toolkit-react.legacy-esm.js.map +1 -1
- package/dist/react/redux-toolkit-react.modern.mjs +23 -25
- package/dist/react/redux-toolkit-react.modern.mjs.map +1 -1
- package/dist/redux-toolkit.browser.mjs +1 -2
- package/dist/redux-toolkit.browser.mjs.map +1 -1
- package/dist/redux-toolkit.legacy-esm.js +1748 -2201
- package/dist/redux-toolkit.legacy-esm.js.map +1 -1
- package/dist/redux-toolkit.modern.mjs +1670 -2171
- package/dist/redux-toolkit.modern.mjs.map +1 -1
- package/package.json +13 -29
- package/skills/build-modern-redux-apps/modern-redux/SKILL.md +23 -14
- package/skills/build-modern-redux-apps/modern-redux/references/store-lifetime.md +6 -6
- package/skills/build-modern-redux-apps/redux-dataflow/SKILL.md +13 -10
- package/skills/evolve-and-diagnose-redux-apps/debug-redux-toolkit-apps/SKILL.md +6 -6
- package/skills/evolve-and-diagnose-redux-apps/migrate-to-modern-redux/SKILL.md +7 -8
- package/skills/manage-server-data/adopt-rtk-query/SKILL.md +13 -11
- package/skills/model-redux-state/build-slices-and-selectors/SKILL.md +26 -14
- package/skills/model-redux-state/design-state-ownership/SKILL.md +11 -12
- package/skills/model-redux-state/design-state-ownership/references/state-ownership.md +6 -6
- package/skills/orchestrate-side-effects/handle-side-effects/SKILL.md +27 -23
- package/skills/orchestrate-side-effects/handle-side-effects/references/listener-workflows.md +4 -4
- package/src/autoBatchEnhancer.ts +5 -3
- package/src/combineSlices.ts +5 -5
- package/src/createAction.ts +11 -6
- package/src/createAsyncThunk.ts +14 -2
- package/src/createReducer.ts +1 -1
- package/src/createSlice.ts +9 -4
- package/src/dynamicMiddleware/index.ts +21 -5
- package/src/entities/models.ts +2 -1
- package/src/entities/sorted_state_adapter.ts +35 -24
- package/src/entities/unsorted_state_adapter.ts +1 -1
- package/src/immutableStateInvariantMiddleware.ts +34 -5
- package/src/listenerMiddleware/types.ts +10 -10
- package/src/mapBuilders.ts +2 -5
- package/src/matchers.ts +7 -1
- package/src/query/core/apiState.ts +1 -1
- package/src/query/core/buildInitiate.ts +19 -15
- package/src/query/core/buildMiddleware/cacheLifecycle.ts +3 -1
- package/src/query/core/buildMiddleware/index.ts +1 -1
- package/src/query/core/buildMiddleware/invalidationByTags.ts +4 -1
- package/src/query/core/buildMiddleware/polling.ts +12 -3
- package/src/query/core/buildMiddleware/types.ts +5 -2
- package/src/query/core/buildSlice.ts +2 -2
- package/src/query/core/buildThunks.ts +19 -0
- package/src/query/core/module.ts +9 -3
- package/src/query/createApi.ts +4 -1
- package/src/query/endpointDefinitions.ts +15 -9
- package/src/query/fetchBaseQuery.ts +1 -1
- package/src/query/react/buildHooks.ts +54 -51
- package/src/query/react/namedHooks.ts +28 -24
- package/src/query/utils/isAbsoluteUrl.ts +8 -3
- package/src/serializableStateInvariantMiddleware.ts +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { ActionCreator,
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { ThunkMiddleware, ThunkDispatch } from 'redux-thunk';
|
|
9
|
-
export { ThunkAction, ThunkDispatch, ThunkMiddleware } from 'redux-thunk';
|
|
10
|
-
import { UncheckedIndexedAccess } from './uncheckedindexed.js';
|
|
11
|
-
|
|
1
|
+
import { Action, ActionCreator, Dispatch, Middleware, MiddlewareAPI, PreloadedStateShapeFromReducersMapObject, Reducer, ReducersMapObject, StateFromReducersMapObject, Store, StoreEnhancer, UnknownAction } from "redux";
|
|
2
|
+
import { Draft, Draft as Draft$1, WritableDraft, current, freeze, isDraft, original, produce as createNextState } from "immer";
|
|
3
|
+
import { CreateSelectorFunction, OutputSelector, Selector, Selector as Selector$1, createSelector, createSelectorCreator, lruMemoize, weakMapMemoize } from "reselect";
|
|
4
|
+
import { ThunkAction, ThunkDispatch, ThunkDispatch as ThunkDispatch$1, ThunkMiddleware, ThunkMiddleware as ThunkMiddleware$1 } from "redux-thunk";
|
|
5
|
+
import { UncheckedIndexedAccess } from "./uncheckedindexed.js";
|
|
6
|
+
export * from "redux";
|
|
7
|
+
//#region src/createDraftSafeSelector.d.ts
|
|
12
8
|
declare const createDraftSafeSelectorCreator: typeof createSelectorCreator;
|
|
13
9
|
/**
|
|
14
10
|
* "Draft-Safe" version of `reselect`'s `createSelector`:
|
|
@@ -17,219 +13,222 @@ declare const createDraftSafeSelectorCreator: typeof createSelectorCreator;
|
|
|
17
13
|
* that might be possibly outdated if the draft has been modified since.
|
|
18
14
|
* @public
|
|
19
15
|
*/
|
|
20
|
-
declare const createDraftSafeSelector: reselect.CreateSelectorFunction<typeof weakMapMemoize, typeof weakMapMemoize, any>;
|
|
21
|
-
|
|
16
|
+
declare const createDraftSafeSelector: import("reselect").CreateSelectorFunction<typeof weakMapMemoize, typeof weakMapMemoize, any>;
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/devtoolsExtension.d.ts
|
|
22
19
|
/**
|
|
23
20
|
* @public
|
|
24
21
|
*/
|
|
25
22
|
interface DevToolsEnhancerOptions {
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* [JSON replacer function](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter) used for both actions and states stringify.
|
|
78
|
-
* In addition, you can specify a data type by adding a [`__serializedType__`](https://github.com/zalmoxisus/remotedev-serialize/blob/master/helpers/index.js#L4)
|
|
79
|
-
* key. So you can deserialize it back while importing or persisting data.
|
|
80
|
-
* Moreover, it will also [show a nice preview showing the provided custom type](https://cloud.githubusercontent.com/assets/7957859/21814330/a17d556a-d761-11e6-85ef-159dd12f36c5.png):
|
|
81
|
-
*/
|
|
82
|
-
replacer?: (key: string, value: unknown) => any;
|
|
83
|
-
/**
|
|
84
|
-
* [JSON `reviver` function](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter)
|
|
85
|
-
* used for parsing the imported actions and states. See [`remotedev-serialize`](https://github.com/zalmoxisus/remotedev-serialize/blob/master/immutable/serialize.js#L8-L41)
|
|
86
|
-
* as an example on how to serialize special data types and get them back.
|
|
87
|
-
*/
|
|
88
|
-
reviver?: (key: string, value: unknown) => any;
|
|
89
|
-
/**
|
|
90
|
-
* Automatically serialize/deserialize immutablejs via [remotedev-serialize](https://github.com/zalmoxisus/remotedev-serialize).
|
|
91
|
-
* Just pass the Immutable library. It will support all ImmutableJS structures. You can even export them into a file and get them back.
|
|
92
|
-
* The only exception is `Record` class, for which you should pass this in addition the references to your classes in `refs`.
|
|
93
|
-
*/
|
|
94
|
-
immutable?: any;
|
|
95
|
-
/**
|
|
96
|
-
* ImmutableJS `Record` classes used to make possible restore its instances back when importing, persisting...
|
|
97
|
-
*/
|
|
98
|
-
refs?: any;
|
|
23
|
+
/**
|
|
24
|
+
* the instance name to be showed on the monitor page. Default value is `document.title`.
|
|
25
|
+
* If not specified and there's no document title, it will consist of `tabId` and `instanceId`.
|
|
26
|
+
*/
|
|
27
|
+
name?: string;
|
|
28
|
+
/**
|
|
29
|
+
* action creators functions to be available in the Dispatcher.
|
|
30
|
+
*/
|
|
31
|
+
actionCreators?: ActionCreator<any>[] | {
|
|
32
|
+
[key: string]: ActionCreator<any>;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* if more than one action is dispatched in the indicated interval, all new actions will be collected and sent at once.
|
|
36
|
+
* It is the joint between performance and speed. When set to `0`, all actions will be sent instantly.
|
|
37
|
+
* Set it to a higher value when experiencing perf issues (also `maxAge` to a lower value).
|
|
38
|
+
*
|
|
39
|
+
* @default 500 ms.
|
|
40
|
+
*/
|
|
41
|
+
latency?: number;
|
|
42
|
+
/**
|
|
43
|
+
* (> 1) - maximum allowed actions to be stored in the history tree. The oldest actions are removed once maxAge is reached. It's critical for performance.
|
|
44
|
+
*
|
|
45
|
+
* @default 50
|
|
46
|
+
*/
|
|
47
|
+
maxAge?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Customizes how actions and state are serialized and deserialized. Can be a boolean or object. If given a boolean, the behavior is the same as if you
|
|
50
|
+
* were to pass an object and specify `options` as a boolean. Giving an object allows fine-grained customization using the `replacer` and `reviver`
|
|
51
|
+
* functions.
|
|
52
|
+
*/
|
|
53
|
+
serialize?: boolean | {
|
|
54
|
+
/**
|
|
55
|
+
* - `undefined` - will use regular `JSON.stringify` to send data (it's the fast mode).
|
|
56
|
+
* - `false` - will handle also circular references.
|
|
57
|
+
* - `true` - will handle also date, regex, undefined, error objects, symbols, maps, sets and functions.
|
|
58
|
+
* - object, which contains `date`, `regex`, `undefined`, `error`, `symbol`, `map`, `set` and `function` keys.
|
|
59
|
+
* For each of them you can indicate if to include (by setting as `true`).
|
|
60
|
+
* For `function` key you can also specify a custom function which handles serialization.
|
|
61
|
+
* See [`jsan`](https://github.com/kolodny/jsan) for more details.
|
|
62
|
+
*/
|
|
63
|
+
options?: undefined | boolean | {
|
|
64
|
+
date?: true;
|
|
65
|
+
regex?: true;
|
|
66
|
+
undefined?: true;
|
|
67
|
+
error?: true;
|
|
68
|
+
symbol?: true;
|
|
69
|
+
map?: true;
|
|
70
|
+
set?: true;
|
|
71
|
+
function?: true | ((fn: (...args: any[]) => any) => string);
|
|
99
72
|
};
|
|
100
73
|
/**
|
|
101
|
-
*
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*/
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
*
|
|
121
|
-
*/
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
74
|
+
* [JSON replacer function](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter) used for both actions and states stringify.
|
|
75
|
+
* In addition, you can specify a data type by adding a [`__serializedType__`](https://github.com/zalmoxisus/remotedev-serialize/blob/master/helpers/index.js#L4)
|
|
76
|
+
* key. So you can deserialize it back while importing or persisting data.
|
|
77
|
+
* Moreover, it will also [show a nice preview showing the provided custom type](https://cloud.githubusercontent.com/assets/7957859/21814330/a17d556a-d761-11e6-85ef-159dd12f36c5.png):
|
|
78
|
+
*/
|
|
79
|
+
replacer?: (key: string, value: unknown) => any;
|
|
80
|
+
/**
|
|
81
|
+
* [JSON `reviver` function](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter)
|
|
82
|
+
* used for parsing the imported actions and states. See [`remotedev-serialize`](https://github.com/zalmoxisus/remotedev-serialize/blob/master/immutable/serialize.js#L8-L41)
|
|
83
|
+
* as an example on how to serialize special data types and get them back.
|
|
84
|
+
*/
|
|
85
|
+
reviver?: (key: string, value: unknown) => any;
|
|
86
|
+
/**
|
|
87
|
+
* Automatically serialize/deserialize immutablejs via [remotedev-serialize](https://github.com/zalmoxisus/remotedev-serialize).
|
|
88
|
+
* Just pass the Immutable library. It will support all ImmutableJS structures. You can even export them into a file and get them back.
|
|
89
|
+
* The only exception is `Record` class, for which you should pass this in addition the references to your classes in `refs`.
|
|
90
|
+
*/
|
|
91
|
+
immutable?: any;
|
|
92
|
+
/**
|
|
93
|
+
* ImmutableJS `Record` classes used to make possible restore its instances back when importing, persisting...
|
|
94
|
+
*/
|
|
95
|
+
refs?: any;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* function which takes `action` object and id number as arguments, and should return `action` object back.
|
|
99
|
+
*/
|
|
100
|
+
actionSanitizer?: <A extends Action>(action: A, id: number) => A;
|
|
101
|
+
/**
|
|
102
|
+
* function which takes `state` object and index as arguments, and should return `state` object back.
|
|
103
|
+
*/
|
|
104
|
+
stateSanitizer?: <S>(state: S, index: number) => S;
|
|
105
|
+
/**
|
|
106
|
+
* *string or array of strings as regex* - actions types to be hidden / shown in the monitors (while passed to the reducers).
|
|
107
|
+
* If `actionsAllowlist` specified, `actionsDenylist` is ignored.
|
|
108
|
+
*/
|
|
109
|
+
actionsDenylist?: string | string[];
|
|
110
|
+
/**
|
|
111
|
+
* *string or array of strings as regex* - actions types to be hidden / shown in the monitors (while passed to the reducers).
|
|
112
|
+
* If `actionsAllowlist` specified, `actionsDenylist` is ignored.
|
|
113
|
+
*/
|
|
114
|
+
actionsAllowlist?: string | string[];
|
|
115
|
+
/**
|
|
116
|
+
* called for every action before sending, takes `state` and `action` object, and returns `true` in case it allows sending the current data to the monitor.
|
|
117
|
+
* Use it as a more advanced version of `actionsDenylist`/`actionsAllowlist` parameters.
|
|
118
|
+
*/
|
|
119
|
+
predicate?: <S, A extends Action>(state: S, action: A) => boolean;
|
|
120
|
+
/**
|
|
121
|
+
* if specified as `false`, it will not record the changes till clicking on `Start recording` button.
|
|
122
|
+
* Available only for Redux enhancer, for others use `autoPause`.
|
|
123
|
+
*
|
|
124
|
+
* @default true
|
|
125
|
+
*/
|
|
126
|
+
shouldRecordChanges?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* if specified, whenever clicking on `Pause recording` button and there are actions in the history log, will add this action type.
|
|
129
|
+
* If not specified, will commit when paused. Available only for Redux enhancer.
|
|
130
|
+
*
|
|
131
|
+
* @default "@@PAUSED""
|
|
132
|
+
*/
|
|
133
|
+
pauseActionType?: string;
|
|
134
|
+
/**
|
|
135
|
+
* auto pauses when the extension’s window is not opened, and so has zero impact on your app when not in use.
|
|
136
|
+
* Not available for Redux enhancer (as it already does it but storing the data to be sent).
|
|
137
|
+
*
|
|
138
|
+
* @default false
|
|
139
|
+
*/
|
|
140
|
+
autoPause?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* if specified as `true`, it will not allow any non-monitor actions to be dispatched till clicking on `Unlock changes` button.
|
|
143
|
+
* Available only for Redux enhancer.
|
|
144
|
+
*
|
|
145
|
+
* @default false
|
|
146
|
+
*/
|
|
147
|
+
shouldStartLocked?: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* if set to `false`, will not recompute the states on hot reloading (or on replacing the reducers). Available only for Redux enhancer.
|
|
150
|
+
*
|
|
151
|
+
* @default true
|
|
152
|
+
*/
|
|
153
|
+
shouldHotReload?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* if specified as `true`, whenever there's an exception in reducers, the monitors will show the error message, and next actions will not be dispatched.
|
|
156
|
+
*
|
|
157
|
+
* @default false
|
|
158
|
+
*/
|
|
159
|
+
shouldCatchErrors?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* If you want to restrict the extension, specify the features you allow.
|
|
162
|
+
* If not specified, all of the features are enabled. When set as an object, only those included as `true` will be allowed.
|
|
163
|
+
* Note that except `true`/`false`, `import` and `export` can be set as `custom` (which is by default for Redux enhancer), meaning that the importing/exporting occurs on the client side.
|
|
164
|
+
* Otherwise, you'll get/set the data right from the monitor part.
|
|
165
|
+
*/
|
|
166
|
+
features?: {
|
|
167
|
+
/**
|
|
168
|
+
* start/pause recording of dispatched actions
|
|
169
|
+
*/
|
|
170
|
+
pause?: boolean;
|
|
171
|
+
/**
|
|
172
|
+
* lock/unlock dispatching actions and side effects
|
|
173
|
+
*/
|
|
174
|
+
lock?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* persist states on page reloading
|
|
177
|
+
*/
|
|
178
|
+
persist?: boolean;
|
|
179
|
+
/**
|
|
180
|
+
* export history of actions in a file
|
|
181
|
+
*/
|
|
182
|
+
export?: boolean | 'custom';
|
|
183
|
+
/**
|
|
184
|
+
* import history of actions from a file
|
|
185
|
+
*/
|
|
186
|
+
import?: boolean | 'custom';
|
|
187
|
+
/**
|
|
188
|
+
* jump back and forth (time traveling)
|
|
189
|
+
*/
|
|
190
|
+
jump?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* skip (cancel) actions
|
|
193
|
+
*/
|
|
194
|
+
skip?: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* drag and drop actions in the history list
|
|
197
|
+
*/
|
|
198
|
+
reorder?: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* dispatch custom actions or action creators
|
|
201
|
+
*/
|
|
202
|
+
dispatch?: boolean;
|
|
203
|
+
/**
|
|
204
|
+
* generate tests for the selected actions
|
|
205
|
+
*/
|
|
206
|
+
test?: boolean;
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Set to true or a stacktrace-returning function to record call stack traces for dispatched actions.
|
|
210
|
+
* Defaults to false.
|
|
211
|
+
*/
|
|
212
|
+
trace?: boolean | (<A extends Action>(action: A) => string);
|
|
213
|
+
/**
|
|
214
|
+
* The maximum number of stack trace entries to record per action. Defaults to 10.
|
|
215
|
+
*/
|
|
216
|
+
traceLimit?: number;
|
|
220
217
|
}
|
|
221
|
-
|
|
218
|
+
//#endregion
|
|
219
|
+
//#region src/actionCreatorInvariantMiddleware.d.ts
|
|
222
220
|
interface ActionCreatorInvariantMiddlewareOptions {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
221
|
+
/**
|
|
222
|
+
* The function to identify whether a value is an action creator.
|
|
223
|
+
* The default checks for a function with a static type property and match method.
|
|
224
|
+
*/
|
|
225
|
+
isActionCreator?: (action: unknown) => action is Function & {
|
|
226
|
+
type?: unknown;
|
|
227
|
+
};
|
|
230
228
|
}
|
|
231
229
|
declare function createActionCreatorInvariantMiddleware(options?: ActionCreatorInvariantMiddlewareOptions): Middleware;
|
|
232
|
-
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region src/serializableStateInvariantMiddleware.d.ts
|
|
233
232
|
/**
|
|
234
233
|
* Returns true if the passed value is "plain", i.e. a value that is either
|
|
235
234
|
* directly JSON-serializable (boolean, number, string, array, plain object)
|
|
@@ -241,8 +240,8 @@ declare function createActionCreatorInvariantMiddleware(options?: ActionCreatorI
|
|
|
241
240
|
*/
|
|
242
241
|
declare function isPlain(val: any): boolean;
|
|
243
242
|
interface NonSerializableValue {
|
|
244
|
-
|
|
245
|
-
|
|
243
|
+
keyPath: string;
|
|
244
|
+
value: unknown;
|
|
246
245
|
}
|
|
247
246
|
type IgnoredPaths = readonly (string | RegExp)[];
|
|
248
247
|
/**
|
|
@@ -255,53 +254,53 @@ declare function findNonSerializableValue(value: unknown, path?: string, isSeria
|
|
|
255
254
|
* @public
|
|
256
255
|
*/
|
|
257
256
|
interface SerializableStateInvariantMiddlewareOptions {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
257
|
+
/**
|
|
258
|
+
* The function to check if a value is considered serializable. This
|
|
259
|
+
* function is applied recursively to every value contained in the
|
|
260
|
+
* state. Defaults to `isPlain()`.
|
|
261
|
+
*/
|
|
262
|
+
isSerializable?: (value: any) => boolean;
|
|
263
|
+
/**
|
|
264
|
+
* The function that will be used to retrieve entries from each
|
|
265
|
+
* value. If unspecified, `Object.entries` will be used. Defaults
|
|
266
|
+
* to `undefined`.
|
|
267
|
+
*/
|
|
268
|
+
getEntries?: (value: any) => [string, any][];
|
|
269
|
+
/**
|
|
270
|
+
* An array of action types to ignore when checking for serializability.
|
|
271
|
+
* Defaults to []
|
|
272
|
+
*/
|
|
273
|
+
ignoredActions?: string[];
|
|
274
|
+
/**
|
|
275
|
+
* An array of dot-separated path strings or regular expressions to ignore
|
|
276
|
+
* when checking for serializability, Defaults to
|
|
277
|
+
* ['meta.arg', 'meta.baseQueryMeta']
|
|
278
|
+
*/
|
|
279
|
+
ignoredActionPaths?: (string | RegExp)[];
|
|
280
|
+
/**
|
|
281
|
+
* An array of dot-separated path strings or regular expressions to ignore
|
|
282
|
+
* when checking for serializability, Defaults to []
|
|
283
|
+
*/
|
|
284
|
+
ignoredPaths?: (string | RegExp)[];
|
|
285
|
+
/**
|
|
286
|
+
* Execution time warning threshold. If the middleware takes longer
|
|
287
|
+
* than `warnAfter` ms, a warning will be displayed in the console.
|
|
288
|
+
* Defaults to 32ms.
|
|
289
|
+
*/
|
|
290
|
+
warnAfter?: number;
|
|
291
|
+
/**
|
|
292
|
+
* Opt out of checking state. When set to `true`, other state-related params will be ignored.
|
|
293
|
+
*/
|
|
294
|
+
ignoreState?: boolean;
|
|
295
|
+
/**
|
|
296
|
+
* Opt out of checking actions. When set to `true`, other action-related params will be ignored.
|
|
297
|
+
*/
|
|
298
|
+
ignoreActions?: boolean;
|
|
299
|
+
/**
|
|
300
|
+
* Opt out of caching the results. The cache uses a WeakSet and speeds up repeated checking processes.
|
|
301
|
+
* The cache is automatically disabled if no browser support for WeakSet is present.
|
|
302
|
+
*/
|
|
303
|
+
disableCache?: boolean;
|
|
305
304
|
}
|
|
306
305
|
/**
|
|
307
306
|
* Creates a middleware that, after every state change, checks if the new
|
|
@@ -313,7 +312,8 @@ interface SerializableStateInvariantMiddlewareOptions {
|
|
|
313
312
|
* @public
|
|
314
313
|
*/
|
|
315
314
|
declare function createSerializableStateInvariantMiddleware(options?: SerializableStateInvariantMiddlewareOptions): Middleware;
|
|
316
|
-
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region src/immutableStateInvariantMiddleware.d.ts
|
|
317
317
|
/**
|
|
318
318
|
* The default `isImmutable` function.
|
|
319
319
|
*
|
|
@@ -327,21 +327,21 @@ type IsImmutableFunc = (value: any) => boolean;
|
|
|
327
327
|
* @public
|
|
328
328
|
*/
|
|
329
329
|
interface ImmutableStateInvariantMiddlewareOptions {
|
|
330
|
-
|
|
330
|
+
/**
|
|
331
331
|
Callback function to check if a value is considered to be immutable.
|
|
332
332
|
This function is applied recursively to every value contained in the state.
|
|
333
333
|
The default implementation will return true for primitive types
|
|
334
334
|
(like numbers, strings, booleans, null and undefined).
|
|
335
335
|
*/
|
|
336
|
-
|
|
337
|
-
|
|
336
|
+
isImmutable?: IsImmutableFunc;
|
|
337
|
+
/**
|
|
338
338
|
An array of dot-separated path strings that match named nodes from
|
|
339
339
|
the root state to ignore when checking for immutability.
|
|
340
340
|
Defaults to undefined
|
|
341
341
|
*/
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
342
|
+
ignoredPaths?: IgnoredPaths;
|
|
343
|
+
/** Print a warning if checks take longer than N ms. Default: 32ms */
|
|
344
|
+
warnAfter?: number;
|
|
345
345
|
}
|
|
346
346
|
/**
|
|
347
347
|
* Creates a middleware that checks whether any state was mutated in between
|
|
@@ -353,19 +353,21 @@ interface ImmutableStateInvariantMiddlewareOptions {
|
|
|
353
353
|
* @public
|
|
354
354
|
*/
|
|
355
355
|
declare function createImmutableStateInvariantMiddleware(options?: ImmutableStateInvariantMiddlewareOptions): Middleware;
|
|
356
|
-
|
|
356
|
+
//#endregion
|
|
357
|
+
//#region src/utils.d.ts
|
|
357
358
|
declare class Tuple<Items extends ReadonlyArray<unknown> = []> extends Array<Items[number]> {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
359
|
+
constructor(length: number);
|
|
360
|
+
constructor(...items: Items);
|
|
361
|
+
static get [Symbol.species](): any;
|
|
362
|
+
concat<AdditionalItems extends ReadonlyArray<unknown>>(items: Tuple<AdditionalItems>): Tuple<[...Items, ...AdditionalItems]>;
|
|
363
|
+
concat<AdditionalItems extends ReadonlyArray<unknown>>(items: AdditionalItems): Tuple<[...Items, ...AdditionalItems]>;
|
|
364
|
+
concat<AdditionalItems extends ReadonlyArray<unknown>>(...items: AdditionalItems): Tuple<[...Items, ...AdditionalItems]>;
|
|
365
|
+
prepend<AdditionalItems extends ReadonlyArray<unknown>>(items: Tuple<AdditionalItems>): Tuple<[...AdditionalItems, ...Items]>;
|
|
366
|
+
prepend<AdditionalItems extends ReadonlyArray<unknown>>(items: AdditionalItems): Tuple<[...AdditionalItems, ...Items]>;
|
|
367
|
+
prepend<AdditionalItems extends ReadonlyArray<unknown>>(...items: AdditionalItems): Tuple<[...AdditionalItems, ...Items]>;
|
|
367
368
|
}
|
|
368
|
-
|
|
369
|
+
//#endregion
|
|
370
|
+
//#region src/tsHelpers.d.ts
|
|
369
371
|
/**
|
|
370
372
|
* return True if T is `any`, otherwise return False
|
|
371
373
|
* taken from https://github.com/joonhocho/tsdef
|
|
@@ -410,11 +412,8 @@ type IsUnknownOrNonInferrable<T, True, False> = AtLeastTS35<IsUnknown<T, True, F
|
|
|
410
412
|
/**
|
|
411
413
|
* Convert a Union type `(A|B)` to an intersection type `(A&B)`
|
|
412
414
|
*/
|
|
413
|
-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
414
|
-
type ExcludeFromTuple<T, E, Acc extends unknown[] = []> = T extends [
|
|
415
|
-
infer Head,
|
|
416
|
-
...infer Tail
|
|
417
|
-
] ? ExcludeFromTuple<Tail, E, [...Acc, ...([Head] extends [E] ? [] : [Head])]> : Acc;
|
|
415
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
416
|
+
type ExcludeFromTuple<T, E, Acc extends unknown[] = []> = T extends [infer Head, ...infer Tail] ? ExcludeFromTuple<Tail, E, [...Acc, ...([Head] extends [E] ? [] : [Head])]> : Acc;
|
|
418
417
|
type ExtractDispatchFromMiddlewareTuple<MiddlewareTuple extends readonly any[], Acc extends {}> = MiddlewareTuple extends [infer Head, ...infer Tail] ? ExtractDispatchFromMiddlewareTuple<Tail, Acc & (Head extends Middleware<infer D> ? IsAny<D, {}, D> : {})> : Acc;
|
|
419
418
|
type ExtractDispatchExtensions<M> = M extends Tuple<infer MiddlewareTuple> ? ExtractDispatchFromMiddlewareTuple<MiddlewareTuple, {}> : M extends ReadonlyArray<Middleware> ? ExtractDispatchFromMiddlewareTuple<[...M], {}> : never;
|
|
420
419
|
type ExtractStoreExtensionsFromEnhancerTuple<EnhancerTuple extends readonly any[], Acc extends {}> = EnhancerTuple extends [infer Head, ...infer Tail] ? ExtractStoreExtensionsFromEnhancerTuple<Tail, Acc & (Head extends StoreEnhancer<infer Ext> ? IsAny<Ext, {}, Ext> : {})> : Acc;
|
|
@@ -425,18 +424,16 @@ type NonUndefined<T> = T extends undefined ? never : T;
|
|
|
425
424
|
type WithRequiredProp<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
426
425
|
type WithOptionalProp<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
427
426
|
interface TypeGuard<T> {
|
|
428
|
-
|
|
427
|
+
(value: any): value is T;
|
|
429
428
|
}
|
|
430
429
|
interface HasMatchFunction<T> {
|
|
431
|
-
|
|
430
|
+
match: TypeGuard<T>;
|
|
432
431
|
}
|
|
433
432
|
/** @public */
|
|
434
433
|
type Matcher<T> = HasMatchFunction<T> | TypeGuard<T>;
|
|
435
434
|
/** @public */
|
|
436
435
|
type ActionFromMatcher<M extends Matcher<any>> = M extends Matcher<infer T> ? T : never;
|
|
437
|
-
type Id<T> = {
|
|
438
|
-
[K in keyof T]: T[K];
|
|
439
|
-
} & {};
|
|
436
|
+
type Id<T> = { [K in keyof T]: T[K]; } & {};
|
|
440
437
|
type Tail<T extends any[]> = T extends [any, ...infer Tail] ? Tail : never;
|
|
441
438
|
type UnknownIfNonSpecific<T> = {} extends T ? unknown : T;
|
|
442
439
|
/**
|
|
@@ -444,47 +441,49 @@ type UnknownIfNonSpecific<T> = {} extends T ? unknown : T;
|
|
|
444
441
|
* @see https://github.com/reduxjs/redux-toolkit/issues/4101
|
|
445
442
|
*/
|
|
446
443
|
type SafePromise<T> = Promise<T> & {
|
|
447
|
-
|
|
444
|
+
__linterBrands: 'SafePromise';
|
|
448
445
|
};
|
|
449
|
-
|
|
446
|
+
//#endregion
|
|
447
|
+
//#region src/getDefaultMiddleware.d.ts
|
|
450
448
|
interface ThunkOptions<E = any> {
|
|
451
|
-
|
|
449
|
+
extraArgument: E;
|
|
452
450
|
}
|
|
453
451
|
interface GetDefaultMiddlewareOptions {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
452
|
+
thunk?: boolean | ThunkOptions;
|
|
453
|
+
immutableCheck?: boolean | ImmutableStateInvariantMiddlewareOptions;
|
|
454
|
+
serializableCheck?: boolean | SerializableStateInvariantMiddlewareOptions;
|
|
455
|
+
actionCreatorCheck?: boolean | ActionCreatorInvariantMiddlewareOptions;
|
|
458
456
|
}
|
|
459
457
|
type ThunkMiddlewareFor<S, O extends GetDefaultMiddlewareOptions = {}> = O extends {
|
|
460
|
-
|
|
458
|
+
thunk: false;
|
|
461
459
|
} ? never : O extends {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
} ? ThunkMiddleware<S, UnknownAction, E> : ThunkMiddleware<S, UnknownAction>;
|
|
460
|
+
thunk: {
|
|
461
|
+
extraArgument: infer E;
|
|
462
|
+
};
|
|
463
|
+
} ? ThunkMiddleware$1<S, UnknownAction, E> : ThunkMiddleware$1<S, UnknownAction>;
|
|
466
464
|
type GetDefaultMiddleware<S = any> = <O extends GetDefaultMiddlewareOptions = {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
465
|
+
thunk: true;
|
|
466
|
+
immutableCheck: true;
|
|
467
|
+
serializableCheck: true;
|
|
468
|
+
actionCreatorCheck: true;
|
|
471
469
|
}>(options?: O) => Tuple<ExcludeFromTuple<[ThunkMiddlewareFor<S, O>], never>>;
|
|
472
|
-
|
|
470
|
+
//#endregion
|
|
471
|
+
//#region src/autoBatchEnhancer.d.ts
|
|
473
472
|
declare const SHOULD_AUTOBATCH = "RTK_autoBatch";
|
|
474
473
|
declare const prepareAutoBatched: <T>() => (payload: T) => {
|
|
475
|
-
|
|
476
|
-
|
|
474
|
+
payload: T;
|
|
475
|
+
meta: unknown;
|
|
477
476
|
};
|
|
478
477
|
type AutoBatchOptions = {
|
|
479
|
-
|
|
478
|
+
type: 'tick';
|
|
480
479
|
} | {
|
|
481
|
-
|
|
482
|
-
|
|
480
|
+
type: 'timer';
|
|
481
|
+
timeout: number;
|
|
483
482
|
} | {
|
|
484
|
-
|
|
483
|
+
type: 'raf';
|
|
485
484
|
} | {
|
|
486
|
-
|
|
487
|
-
|
|
485
|
+
type: 'callback';
|
|
486
|
+
queueNotification: (notify: () => void) => void;
|
|
488
487
|
};
|
|
489
488
|
/**
|
|
490
489
|
* A Redux store enhancer that watches for "low-priority" actions, and delays
|
|
@@ -499,7 +498,7 @@ type AutoBatchOptions = {
|
|
|
499
498
|
* This can be added to `action.meta` manually, or by using the
|
|
500
499
|
* `prepareAutoBatched` helper.
|
|
501
500
|
*
|
|
502
|
-
* By default, it will queue a notification
|
|
501
|
+
* By default, it will queue a notification using `requestAnimationFrame`.
|
|
503
502
|
* However, you can pass several other options to configure the behavior:
|
|
504
503
|
* - `{type: 'tick'}`: queues using `queueMicrotask`
|
|
505
504
|
* - `{type: 'timer', timeout: number}`: queues using `setTimeout`
|
|
@@ -509,61 +508,63 @@ type AutoBatchOptions = {
|
|
|
509
508
|
*
|
|
510
509
|
*/
|
|
511
510
|
declare const autoBatchEnhancer: (options?: AutoBatchOptions) => StoreEnhancer;
|
|
512
|
-
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region src/getDefaultEnhancers.d.ts
|
|
513
513
|
type GetDefaultEnhancersOptions = {
|
|
514
|
-
|
|
514
|
+
autoBatch?: boolean | AutoBatchOptions;
|
|
515
515
|
};
|
|
516
516
|
type GetDefaultEnhancers<M extends Middlewares<any>> = (options?: GetDefaultEnhancersOptions) => Tuple<[StoreEnhancer<{
|
|
517
|
-
|
|
517
|
+
dispatch: ExtractDispatchExtensions<M>;
|
|
518
518
|
}>]>;
|
|
519
|
-
|
|
519
|
+
//#endregion
|
|
520
|
+
//#region src/configureStore.d.ts
|
|
520
521
|
/**
|
|
521
522
|
* Options for `configureStore()`.
|
|
522
523
|
*
|
|
523
524
|
* @public
|
|
524
525
|
*/
|
|
525
526
|
interface ConfigureStoreOptions<S = any, A extends Action = UnknownAction, M extends Tuple<Middlewares<S>> = Tuple<Middlewares<S>>, E extends Tuple<Enhancers> = Tuple<Enhancers>, P = S> {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
527
|
+
/**
|
|
528
|
+
* A single reducer function that will be used as the root reducer, or an
|
|
529
|
+
* object of slice reducers that will be passed to `combineReducers()`.
|
|
530
|
+
*/
|
|
531
|
+
reducer: Reducer<S, A, P> | ReducersMapObject<S, A, P>;
|
|
532
|
+
/**
|
|
533
|
+
* An array of Redux middleware to install, or a callback receiving `getDefaultMiddleware` and returning a Tuple of middleware.
|
|
534
|
+
* If not supplied, defaults to the set of middleware returned by `getDefaultMiddleware()`.
|
|
535
|
+
*
|
|
536
|
+
* @example `middleware: (gDM) => gDM().concat(logger, apiMiddleware, yourCustomMiddleware)`
|
|
537
|
+
* @see https://redux-toolkit.js.org/api/getDefaultMiddleware#intended-usage
|
|
538
|
+
*/
|
|
539
|
+
middleware?: (getDefaultMiddleware: GetDefaultMiddleware<S>) => M;
|
|
540
|
+
/**
|
|
541
|
+
* Whether to enable Redux DevTools integration. Defaults to `true`.
|
|
542
|
+
*
|
|
543
|
+
* Additional configuration can be done by passing Redux DevTools options
|
|
544
|
+
*/
|
|
545
|
+
devTools?: boolean | DevToolsEnhancerOptions;
|
|
546
|
+
/**
|
|
547
|
+
* Whether to check for duplicate middleware instances. Defaults to `true`.
|
|
548
|
+
*/
|
|
549
|
+
duplicateMiddlewareCheck?: boolean;
|
|
550
|
+
/**
|
|
551
|
+
* The initial state, same as Redux's createStore.
|
|
552
|
+
* You may optionally specify it to hydrate the state
|
|
553
|
+
* from the server in universal apps, or to restore a previously serialized
|
|
554
|
+
* user session. If you use `combineReducers()` to produce the root reducer
|
|
555
|
+
* function (either directly or indirectly by passing an object as `reducer`),
|
|
556
|
+
* this must be an object with the same shape as the reducer map keys.
|
|
557
|
+
*/
|
|
558
|
+
preloadedState?: P;
|
|
559
|
+
/**
|
|
560
|
+
* The store enhancers to apply. See Redux's `createStore()`.
|
|
561
|
+
* All enhancers will be included before the DevTools Extension enhancer.
|
|
562
|
+
* If you need to customize the order of enhancers, supply a callback
|
|
563
|
+
* function that will receive a `getDefaultEnhancers` function that returns a Tuple,
|
|
564
|
+
* and should return a Tuple of enhancers (such as `getDefaultEnhancers().concat(offline)`).
|
|
565
|
+
* If you only need to add middleware, you can use the `middleware` parameter instead.
|
|
566
|
+
*/
|
|
567
|
+
enhancers?: (getDefaultEnhancers: GetDefaultEnhancers<M>) => E;
|
|
567
568
|
}
|
|
568
569
|
type Middlewares<S> = ReadonlyArray<Middleware<{}, S>>;
|
|
569
570
|
type Enhancers = ReadonlyArray<StoreEnhancer>;
|
|
@@ -582,13 +583,11 @@ type EnhancedStore<S = any, A extends Action = UnknownAction, E extends Enhancer
|
|
|
582
583
|
*
|
|
583
584
|
* @public
|
|
584
585
|
*/
|
|
585
|
-
declare function configureStore<S = any, A extends Action = UnknownAction, M extends Tuple<Middlewares<S>> = Tuple<[ThunkMiddlewareFor<S>]>, E extends Tuple<Enhancers> = Tuple<[
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
]>, P = S>(options: ConfigureStoreOptions<S, A, M, E, P>): EnhancedStore<S, A, E>;
|
|
591
|
-
|
|
586
|
+
declare function configureStore<S = any, A extends Action = UnknownAction, M extends Tuple<Middlewares<S>> = Tuple<[ThunkMiddlewareFor<S>]>, E extends Tuple<Enhancers> = Tuple<[StoreEnhancer<{
|
|
587
|
+
dispatch: ExtractDispatchExtensions<M>;
|
|
588
|
+
}>, StoreEnhancer]>, P = S>(options: ConfigureStoreOptions<S, A, M, E, P>): EnhancedStore<S, A, E>;
|
|
589
|
+
//#endregion
|
|
590
|
+
//#region src/createAction.d.ts
|
|
592
591
|
/**
|
|
593
592
|
* An action with a string type and an associated payload. This is the
|
|
594
593
|
* type of action returned by `createAction()` action creators.
|
|
@@ -601,12 +600,12 @@ declare function configureStore<S = any, A extends Action = UnknownAction, M ext
|
|
|
601
600
|
* @public
|
|
602
601
|
*/
|
|
603
602
|
type PayloadAction<P = void, T extends string = string, M = never, E = never> = {
|
|
604
|
-
|
|
605
|
-
|
|
603
|
+
payload: P;
|
|
604
|
+
type: T;
|
|
606
605
|
} & ([M] extends [never] ? {} : {
|
|
607
|
-
|
|
606
|
+
meta: M;
|
|
608
607
|
}) & ([E] extends [never] ? {} : {
|
|
609
|
-
|
|
608
|
+
error: E;
|
|
610
609
|
});
|
|
611
610
|
/**
|
|
612
611
|
* A "prepare" method to be used as the second parameter of `createAction`.
|
|
@@ -616,17 +615,17 @@ type PayloadAction<P = void, T extends string = string, M = never, E = never> =
|
|
|
616
615
|
* @public
|
|
617
616
|
*/
|
|
618
617
|
type PrepareAction<P> = ((...args: any[]) => {
|
|
619
|
-
|
|
618
|
+
payload: P;
|
|
620
619
|
}) | ((...args: any[]) => {
|
|
621
|
-
|
|
622
|
-
|
|
620
|
+
payload: P;
|
|
621
|
+
meta: any;
|
|
623
622
|
}) | ((...args: any[]) => {
|
|
624
|
-
|
|
625
|
-
|
|
623
|
+
payload: P;
|
|
624
|
+
error: any;
|
|
626
625
|
}) | ((...args: any[]) => {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
626
|
+
payload: P;
|
|
627
|
+
meta: any;
|
|
628
|
+
error: any;
|
|
630
629
|
});
|
|
631
630
|
/**
|
|
632
631
|
* Internal version of `ActionCreatorWithPreparedPayload`. Not to be used externally.
|
|
@@ -634,9 +633,9 @@ type PrepareAction<P> = ((...args: any[]) => {
|
|
|
634
633
|
* @internal
|
|
635
634
|
*/
|
|
636
635
|
type _ActionCreatorWithPreparedPayload<PA extends PrepareAction<any> | void, T extends string = string> = PA extends PrepareAction<infer P> ? ActionCreatorWithPreparedPayload<Parameters<PA>, P, T, ReturnType<PA> extends {
|
|
637
|
-
|
|
636
|
+
error: infer E;
|
|
638
637
|
} ? E : never, ReturnType<PA> extends {
|
|
639
|
-
|
|
638
|
+
meta: infer M;
|
|
640
639
|
} ? M : never> : void;
|
|
641
640
|
/**
|
|
642
641
|
* Basic type for all action creators.
|
|
@@ -644,8 +643,8 @@ type _ActionCreatorWithPreparedPayload<PA extends PrepareAction<any> | void, T e
|
|
|
644
643
|
* @inheritdoc {redux#ActionCreator}
|
|
645
644
|
*/
|
|
646
645
|
type BaseActionCreator<P, T extends string, M = never, E = never> = {
|
|
647
|
-
|
|
648
|
-
|
|
646
|
+
type: T;
|
|
647
|
+
match: (action: unknown) => action is PayloadAction<P, T, M, E>;
|
|
649
648
|
};
|
|
650
649
|
/**
|
|
651
650
|
* An action creator that takes multiple arguments that are passed
|
|
@@ -661,12 +660,12 @@ type BaseActionCreator<P, T extends string, M = never, E = never> = {
|
|
|
661
660
|
* @public
|
|
662
661
|
*/
|
|
663
662
|
interface ActionCreatorWithPreparedPayload<Args extends unknown[], P, T extends string = string, E = never, M = never> extends BaseActionCreator<P, T, M, E> {
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
663
|
+
/**
|
|
664
|
+
* Calling this {@link redux#ActionCreator} with `Args` will return
|
|
665
|
+
* an Action with a payload of type `P` and (depending on the `PrepareAction`
|
|
666
|
+
* method used) a `meta`- and `error` property of types `M` and `E` respectively.
|
|
667
|
+
*/
|
|
668
|
+
(...args: Args): PayloadAction<P, T, M, E>;
|
|
670
669
|
}
|
|
671
670
|
/**
|
|
672
671
|
* An action creator of type `T` that takes an optional payload of type `P`.
|
|
@@ -676,12 +675,12 @@ interface ActionCreatorWithPreparedPayload<Args extends unknown[], P, T extends
|
|
|
676
675
|
* @public
|
|
677
676
|
*/
|
|
678
677
|
interface ActionCreatorWithOptionalPayload<P, T extends string = string> extends BaseActionCreator<P, T> {
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
678
|
+
/**
|
|
679
|
+
* Calling this {@link redux#ActionCreator} with an argument will
|
|
680
|
+
* return a {@link PayloadAction} of type `T` with a payload of `P`.
|
|
681
|
+
* Calling it without an argument will return a PayloadAction with a payload of `undefined`.
|
|
682
|
+
*/
|
|
683
|
+
(payload?: P): PayloadAction<P, T>;
|
|
685
684
|
}
|
|
686
685
|
/**
|
|
687
686
|
* An action creator of type `T` that takes no payload.
|
|
@@ -691,11 +690,11 @@ interface ActionCreatorWithOptionalPayload<P, T extends string = string> extends
|
|
|
691
690
|
* @public
|
|
692
691
|
*/
|
|
693
692
|
interface ActionCreatorWithoutPayload<T extends string = string> extends BaseActionCreator<undefined, T> {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
693
|
+
/**
|
|
694
|
+
* Calling this {@link redux#ActionCreator} will
|
|
695
|
+
* return a {@link PayloadAction} of type `T` with a payload of `undefined`
|
|
696
|
+
*/
|
|
697
|
+
(noArgument: void): PayloadAction<undefined, T>;
|
|
699
698
|
}
|
|
700
699
|
/**
|
|
701
700
|
* An action creator of type `T` that requires a payload of type P.
|
|
@@ -705,11 +704,11 @@ interface ActionCreatorWithoutPayload<T extends string = string> extends BaseAct
|
|
|
705
704
|
* @public
|
|
706
705
|
*/
|
|
707
706
|
interface ActionCreatorWithPayload<P, T extends string = string> extends BaseActionCreator<P, T> {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
707
|
+
/**
|
|
708
|
+
* Calling this {@link redux#ActionCreator} with an argument will
|
|
709
|
+
* return a {@link PayloadAction} of type `T` with a payload of `P`
|
|
710
|
+
*/
|
|
711
|
+
(payload: P): PayloadAction<P, T>;
|
|
713
712
|
}
|
|
714
713
|
/**
|
|
715
714
|
* An action creator of type `T` whose `payload` type could not be inferred. Accepts everything as `payload`.
|
|
@@ -719,12 +718,12 @@ interface ActionCreatorWithPayload<P, T extends string = string> extends BaseAct
|
|
|
719
718
|
* @public
|
|
720
719
|
*/
|
|
721
720
|
interface ActionCreatorWithNonInferrablePayload<T extends string = string> extends BaseActionCreator<unknown, T> {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
721
|
+
/**
|
|
722
|
+
* Calling this {@link redux#ActionCreator} with an argument will
|
|
723
|
+
* return a {@link PayloadAction} of type `T` with a payload
|
|
724
|
+
* of exactly the type of the argument.
|
|
725
|
+
*/
|
|
726
|
+
<PT extends unknown>(payload: PT): PayloadAction<PT, T>;
|
|
728
727
|
}
|
|
729
728
|
/**
|
|
730
729
|
* An action creator that produces actions with a `payload` attribute.
|
|
@@ -770,43 +769,44 @@ declare function isActionCreator(action: unknown): action is BaseActionCreator<u
|
|
|
770
769
|
* Returns true if value is an action with a string type and valid Flux Standard Action keys.
|
|
771
770
|
*/
|
|
772
771
|
declare function isFSA(action: unknown): action is {
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
772
|
+
type: string;
|
|
773
|
+
payload?: unknown;
|
|
774
|
+
error?: unknown;
|
|
775
|
+
meta?: unknown;
|
|
777
776
|
};
|
|
778
|
-
type IfPrepareActionMethodProvided<PA extends PrepareAction<any> | void, True, False> = PA extends (...args: any[]) => any ? True : False;
|
|
779
|
-
|
|
777
|
+
type IfPrepareActionMethodProvided<PA extends PrepareAction<any> | void, True, False> = PA extends ((...args: any[]) => any) ? True : False;
|
|
778
|
+
//#endregion
|
|
779
|
+
//#region src/createAsyncThunk.d.ts
|
|
780
780
|
type BaseThunkAPI<S, E, D extends Dispatch = Dispatch, RejectedValue = unknown, RejectedMeta = unknown, FulfilledMeta = unknown> = {
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
781
|
+
dispatch: D;
|
|
782
|
+
getState: () => S;
|
|
783
|
+
extra: E;
|
|
784
|
+
requestId: string;
|
|
785
|
+
signal: AbortSignal;
|
|
786
|
+
abort: (reason?: string) => void;
|
|
787
|
+
rejectWithValue: IsUnknown<RejectedMeta, (value: RejectedValue) => RejectWithValue<RejectedValue, RejectedMeta>, (value: RejectedValue, meta: RejectedMeta) => RejectWithValue<RejectedValue, RejectedMeta>>;
|
|
788
|
+
fulfillWithValue: IsUnknown<FulfilledMeta, <FulfilledValue>(value: FulfilledValue) => FulfilledValue, <FulfilledValue>(value: FulfilledValue, meta: FulfilledMeta) => FulfillWithMeta<FulfilledValue, FulfilledMeta>>;
|
|
789
789
|
};
|
|
790
790
|
/**
|
|
791
791
|
* @public
|
|
792
792
|
*/
|
|
793
793
|
interface SerializedError {
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
794
|
+
name?: string;
|
|
795
|
+
message?: string;
|
|
796
|
+
stack?: string;
|
|
797
|
+
code?: string;
|
|
798
798
|
}
|
|
799
799
|
declare class RejectWithValue<Payload, RejectedMeta> {
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
800
|
+
readonly payload: Payload;
|
|
801
|
+
readonly meta: RejectedMeta;
|
|
802
|
+
private readonly _type;
|
|
803
|
+
constructor(payload: Payload, meta: RejectedMeta);
|
|
804
804
|
}
|
|
805
805
|
declare class FulfillWithMeta<Payload, FulfilledMeta> {
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
806
|
+
readonly payload: Payload;
|
|
807
|
+
readonly meta: FulfilledMeta;
|
|
808
|
+
private readonly _type;
|
|
809
|
+
constructor(payload: Payload, meta: FulfilledMeta);
|
|
810
810
|
}
|
|
811
811
|
/**
|
|
812
812
|
* Serializes an error into a plain object.
|
|
@@ -816,39 +816,39 @@ declare class FulfillWithMeta<Payload, FulfilledMeta> {
|
|
|
816
816
|
*/
|
|
817
817
|
declare const miniSerializeError: (value: any) => SerializedError;
|
|
818
818
|
type AsyncThunkConfig = {
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
819
|
+
state?: unknown;
|
|
820
|
+
dispatch?: ThunkDispatch$1<unknown, unknown, UnknownAction>;
|
|
821
|
+
extra?: unknown;
|
|
822
|
+
rejectValue?: unknown;
|
|
823
|
+
serializedErrorType?: unknown;
|
|
824
|
+
pendingMeta?: unknown;
|
|
825
|
+
fulfilledMeta?: unknown;
|
|
826
|
+
rejectedMeta?: unknown;
|
|
827
827
|
};
|
|
828
828
|
type GetState<ThunkApiConfig> = ThunkApiConfig extends {
|
|
829
|
-
|
|
829
|
+
state: infer State;
|
|
830
830
|
} ? State : unknown;
|
|
831
831
|
type GetExtra<ThunkApiConfig> = ThunkApiConfig extends {
|
|
832
|
-
|
|
832
|
+
extra: infer Extra;
|
|
833
833
|
} ? Extra : unknown;
|
|
834
834
|
type GetDispatch<ThunkApiConfig> = ThunkApiConfig extends {
|
|
835
|
-
|
|
836
|
-
} ? FallbackIfUnknown<Dispatch, ThunkDispatch<GetState<ThunkApiConfig>, GetExtra<ThunkApiConfig>, UnknownAction>> : ThunkDispatch<GetState<ThunkApiConfig>, GetExtra<ThunkApiConfig>, UnknownAction>;
|
|
835
|
+
dispatch: infer Dispatch;
|
|
836
|
+
} ? FallbackIfUnknown<Dispatch, ThunkDispatch$1<GetState<ThunkApiConfig>, GetExtra<ThunkApiConfig>, UnknownAction>> : ThunkDispatch$1<GetState<ThunkApiConfig>, GetExtra<ThunkApiConfig>, UnknownAction>;
|
|
837
837
|
type GetThunkAPI<ThunkApiConfig> = BaseThunkAPI<GetState<ThunkApiConfig>, GetExtra<ThunkApiConfig>, GetDispatch<ThunkApiConfig>, GetRejectValue<ThunkApiConfig>, GetRejectedMeta<ThunkApiConfig>, GetFulfilledMeta<ThunkApiConfig>>;
|
|
838
838
|
type GetRejectValue<ThunkApiConfig> = ThunkApiConfig extends {
|
|
839
|
-
|
|
839
|
+
rejectValue: infer RejectValue;
|
|
840
840
|
} ? RejectValue : unknown;
|
|
841
841
|
type GetPendingMeta<ThunkApiConfig> = ThunkApiConfig extends {
|
|
842
|
-
|
|
842
|
+
pendingMeta: infer PendingMeta;
|
|
843
843
|
} ? PendingMeta : unknown;
|
|
844
844
|
type GetFulfilledMeta<ThunkApiConfig> = ThunkApiConfig extends {
|
|
845
|
-
|
|
845
|
+
fulfilledMeta: infer FulfilledMeta;
|
|
846
846
|
} ? FulfilledMeta : unknown;
|
|
847
847
|
type GetRejectedMeta<ThunkApiConfig> = ThunkApiConfig extends {
|
|
848
|
-
|
|
848
|
+
rejectedMeta: infer RejectedMeta;
|
|
849
849
|
} ? RejectedMeta : unknown;
|
|
850
850
|
type GetSerializedErrorType<ThunkApiConfig> = ThunkApiConfig extends {
|
|
851
|
-
|
|
851
|
+
serializedErrorType: infer GetSerializedErrorType;
|
|
852
852
|
} ? GetSerializedErrorType : SerializedError;
|
|
853
853
|
type MaybePromise<T> = T | Promise<T> | (T extends any ? Promise<T> : never);
|
|
854
854
|
/**
|
|
@@ -875,19 +875,19 @@ type AsyncThunkPayloadCreator<Returned, ThunkArg = void, ThunkApiConfig extends
|
|
|
875
875
|
* @public
|
|
876
876
|
*/
|
|
877
877
|
type AsyncThunkAction<Returned, ThunkArg, ThunkApiConfig extends AsyncThunkConfig> = (dispatch: NonNullable<GetDispatch<ThunkApiConfig>>, getState: () => GetState<ThunkApiConfig>, extra: GetExtra<ThunkApiConfig>) => SafePromise<ReturnType<AsyncThunkFulfilledActionCreator<Returned, ThunkArg>> | ReturnType<AsyncThunkRejectedActionCreator<ThunkArg, ThunkApiConfig>>> & {
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
878
|
+
abort: (reason?: string) => void;
|
|
879
|
+
requestId: string;
|
|
880
|
+
arg: ThunkArg;
|
|
881
|
+
unwrap: () => Promise<Returned>;
|
|
882
882
|
};
|
|
883
883
|
/**
|
|
884
884
|
* Config provided when calling the async thunk action creator.
|
|
885
885
|
*/
|
|
886
886
|
interface AsyncThunkDispatchConfig {
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
887
|
+
/**
|
|
888
|
+
* An external `AbortSignal` that will be tracked by the internal `AbortSignal`.
|
|
889
|
+
*/
|
|
890
|
+
signal?: AbortSignal;
|
|
891
891
|
}
|
|
892
892
|
type AsyncThunkActionCreator<Returned, ThunkArg, ThunkApiConfig extends AsyncThunkConfig> = IsAny<ThunkArg, (arg: ThunkArg, config?: AsyncThunkDispatchConfig) => AsyncThunkAction<Returned, ThunkArg, ThunkApiConfig>, unknown extends ThunkArg ? (arg: ThunkArg, config?: AsyncThunkDispatchConfig) => AsyncThunkAction<Returned, ThunkArg, ThunkApiConfig> : [ThunkArg] extends [void] | [undefined] ? (arg?: undefined, config?: AsyncThunkDispatchConfig) => AsyncThunkAction<Returned, ThunkArg, ThunkApiConfig> : [void] extends [ThunkArg] ? (arg?: ThunkArg, config?: AsyncThunkDispatchConfig) => AsyncThunkAction<Returned, ThunkArg, ThunkApiConfig> : [undefined] extends [ThunkArg] ? WithStrictNullChecks<(arg?: ThunkArg, config?: AsyncThunkDispatchConfig) => AsyncThunkAction<Returned, ThunkArg, ThunkApiConfig>, (arg: ThunkArg, config?: AsyncThunkDispatchConfig) => AsyncThunkAction<Returned, ThunkArg, ThunkApiConfig>> : (arg: ThunkArg, config?: AsyncThunkDispatchConfig) => AsyncThunkAction<Returned, ThunkArg, ThunkApiConfig>>;
|
|
893
893
|
/**
|
|
@@ -896,85 +896,68 @@ type AsyncThunkActionCreator<Returned, ThunkArg, ThunkApiConfig extends AsyncThu
|
|
|
896
896
|
* @public
|
|
897
897
|
*/
|
|
898
898
|
type AsyncThunkOptions<ThunkArg = void, ThunkApiConfig extends AsyncThunkConfig = {}> = {
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
899
|
+
/**
|
|
900
|
+
* A method to control whether the asyncThunk should be executed. Has access to the
|
|
901
|
+
* `arg`, `api.getState()` and `api.extra` arguments.
|
|
902
|
+
*
|
|
903
|
+
* @returns `false` if it should be skipped
|
|
904
|
+
*/
|
|
905
|
+
condition?(arg: ThunkArg, api: Pick<GetThunkAPI<ThunkApiConfig>, 'getState' | 'extra'>): MaybePromise<boolean | undefined>;
|
|
906
|
+
/**
|
|
907
|
+
* If `condition` returns `false`, the asyncThunk will be skipped.
|
|
908
|
+
* This option allows you to control whether a `rejected` action with `meta.condition == false`
|
|
909
|
+
* will be dispatched or not.
|
|
910
|
+
*
|
|
911
|
+
* @default `false`
|
|
912
|
+
*/
|
|
913
|
+
dispatchConditionRejection?: boolean;
|
|
914
|
+
serializeError?: (x: unknown) => GetSerializedErrorType<ThunkApiConfig>;
|
|
915
|
+
/**
|
|
916
|
+
* A function to use when generating the `requestId` for the request sequence.
|
|
917
|
+
*
|
|
918
|
+
* @default `nanoid`
|
|
919
|
+
*/
|
|
920
|
+
idGenerator?: (arg: ThunkArg) => string;
|
|
921
921
|
} & IsUnknown<GetPendingMeta<ThunkApiConfig>, {
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
arg: ThunkArg;
|
|
930
|
-
requestId: string;
|
|
931
|
-
}, api: Pick<GetThunkAPI<ThunkApiConfig>, 'getState' | 'extra'>): GetPendingMeta<ThunkApiConfig>;
|
|
932
|
-
}, {
|
|
933
|
-
/**
|
|
934
|
-
* A method to generate additional properties to be added to `meta` of the pending action.
|
|
935
|
-
*/
|
|
936
|
-
getPendingMeta(base: {
|
|
937
|
-
arg: ThunkArg;
|
|
938
|
-
requestId: string;
|
|
939
|
-
}, api: Pick<GetThunkAPI<ThunkApiConfig>, 'getState' | 'extra'>): GetPendingMeta<ThunkApiConfig>;
|
|
940
|
-
}>;
|
|
941
|
-
type AsyncThunkPendingActionCreator<ThunkArg, ThunkApiConfig = {}> = ActionCreatorWithPreparedPayload<[
|
|
942
|
-
string,
|
|
943
|
-
ThunkArg,
|
|
944
|
-
GetPendingMeta<ThunkApiConfig>?
|
|
945
|
-
], undefined, string, never, {
|
|
922
|
+
/**
|
|
923
|
+
* A method to generate additional properties to be added to `meta` of the pending action.
|
|
924
|
+
*
|
|
925
|
+
* Using this optional overload will not modify the types correctly, this overload is only in place to support JavaScript users.
|
|
926
|
+
* Please use the `ThunkApiConfig` parameter `pendingMeta` to get access to a correctly typed overload
|
|
927
|
+
*/
|
|
928
|
+
getPendingMeta?(base: {
|
|
946
929
|
arg: ThunkArg;
|
|
947
930
|
requestId: string;
|
|
948
|
-
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
GetRejectValue<ThunkApiConfig>?,
|
|
955
|
-
GetRejectedMeta<ThunkApiConfig>?
|
|
956
|
-
], GetRejectValue<ThunkApiConfig> | undefined, string, GetSerializedErrorType<ThunkApiConfig>, {
|
|
931
|
+
}, api: Pick<GetThunkAPI<ThunkApiConfig>, 'getState' | 'extra'>): GetPendingMeta<ThunkApiConfig>;
|
|
932
|
+
}, {
|
|
933
|
+
/**
|
|
934
|
+
* A method to generate additional properties to be added to `meta` of the pending action.
|
|
935
|
+
*/
|
|
936
|
+
getPendingMeta(base: {
|
|
957
937
|
arg: ThunkArg;
|
|
958
938
|
requestId: string;
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
939
|
+
}, api: Pick<GetThunkAPI<ThunkApiConfig>, 'getState' | 'extra'>): GetPendingMeta<ThunkApiConfig>;
|
|
940
|
+
}>;
|
|
941
|
+
type AsyncThunkPendingActionCreator<ThunkArg, ThunkApiConfig = {}> = ActionCreatorWithPreparedPayload<[string, ThunkArg, GetPendingMeta<ThunkApiConfig>?], undefined, string, never, {
|
|
942
|
+
arg: ThunkArg;
|
|
943
|
+
requestId: string;
|
|
944
|
+
requestStatus: 'pending';
|
|
945
|
+
} & GetPendingMeta<ThunkApiConfig>>;
|
|
946
|
+
type AsyncThunkRejectedActionCreator<ThunkArg, ThunkApiConfig = {}> = ActionCreatorWithPreparedPayload<[Error | null, string, ThunkArg, GetRejectValue<ThunkApiConfig>?, GetRejectedMeta<ThunkApiConfig>?], GetRejectValue<ThunkApiConfig> | undefined, string, GetSerializedErrorType<ThunkApiConfig>, {
|
|
947
|
+
arg: ThunkArg;
|
|
948
|
+
requestId: string;
|
|
949
|
+
requestStatus: 'rejected';
|
|
950
|
+
aborted: boolean;
|
|
951
|
+
condition: boolean;
|
|
962
952
|
} & (({
|
|
963
|
-
|
|
964
|
-
} & {
|
|
965
|
-
|
|
966
|
-
}) | ({
|
|
967
|
-
rejectedWithValue: true;
|
|
953
|
+
rejectedWithValue: false;
|
|
954
|
+
} & { [K in keyof GetRejectedMeta<ThunkApiConfig>]?: undefined; }) | ({
|
|
955
|
+
rejectedWithValue: true;
|
|
968
956
|
} & GetRejectedMeta<ThunkApiConfig>))>;
|
|
969
|
-
type AsyncThunkFulfilledActionCreator<Returned, ThunkArg, ThunkApiConfig = {}> = ActionCreatorWithPreparedPayload<[
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
GetFulfilledMeta<ThunkApiConfig>?
|
|
974
|
-
], Returned, string, never, {
|
|
975
|
-
arg: ThunkArg;
|
|
976
|
-
requestId: string;
|
|
977
|
-
requestStatus: 'fulfilled';
|
|
957
|
+
type AsyncThunkFulfilledActionCreator<Returned, ThunkArg, ThunkApiConfig = {}> = ActionCreatorWithPreparedPayload<[Returned, string, ThunkArg, GetFulfilledMeta<ThunkApiConfig>?], Returned, string, never, {
|
|
958
|
+
arg: ThunkArg;
|
|
959
|
+
requestId: string;
|
|
960
|
+
requestStatus: 'fulfilled';
|
|
978
961
|
} & GetFulfilledMeta<ThunkApiConfig>>;
|
|
979
962
|
/**
|
|
980
963
|
* A type describing the return value of `createAsyncThunk`.
|
|
@@ -983,60 +966,61 @@ type AsyncThunkFulfilledActionCreator<Returned, ThunkArg, ThunkApiConfig = {}> =
|
|
|
983
966
|
* @public
|
|
984
967
|
*/
|
|
985
968
|
type AsyncThunk<Returned, ThunkArg, ThunkApiConfig extends AsyncThunkConfig> = AsyncThunkActionCreator<Returned, ThunkArg, ThunkApiConfig> & {
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
969
|
+
pending: AsyncThunkPendingActionCreator<ThunkArg, ThunkApiConfig>;
|
|
970
|
+
rejected: AsyncThunkRejectedActionCreator<ThunkArg, ThunkApiConfig>;
|
|
971
|
+
fulfilled: AsyncThunkFulfilledActionCreator<Returned, ThunkArg, ThunkApiConfig>;
|
|
972
|
+
settled: (action: any) => action is ReturnType<AsyncThunkRejectedActionCreator<ThunkArg, ThunkApiConfig> | AsyncThunkFulfilledActionCreator<Returned, ThunkArg, ThunkApiConfig>>;
|
|
973
|
+
typePrefix: string;
|
|
991
974
|
};
|
|
992
975
|
type OverrideThunkApiConfigs<OldConfig, NewConfig> = Id<NewConfig & Omit<OldConfig, keyof NewConfig>>;
|
|
993
976
|
type CreateAsyncThunkFunction<CurriedThunkApiConfig extends AsyncThunkConfig> = {
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
977
|
+
/**
|
|
978
|
+
*
|
|
979
|
+
* @param typePrefix
|
|
980
|
+
* @param payloadCreator
|
|
981
|
+
* @param options
|
|
982
|
+
*
|
|
983
|
+
* @public
|
|
984
|
+
*/
|
|
985
|
+
<Returned, ThunkArg = void>(typePrefix: string, payloadCreator: AsyncThunkPayloadCreator<Returned, ThunkArg, CurriedThunkApiConfig>, options?: AsyncThunkOptions<ThunkArg, CurriedThunkApiConfig>): AsyncThunk<Returned, ThunkArg, CurriedThunkApiConfig>;
|
|
986
|
+
/**
|
|
987
|
+
*
|
|
988
|
+
* @param typePrefix
|
|
989
|
+
* @param payloadCreator
|
|
990
|
+
* @param options
|
|
991
|
+
*
|
|
992
|
+
* @public
|
|
993
|
+
*/
|
|
994
|
+
<Returned, ThunkArg, ThunkApiConfig extends AsyncThunkConfig>(typePrefix: string, payloadCreator: AsyncThunkPayloadCreator<Returned, ThunkArg, OverrideThunkApiConfigs<CurriedThunkApiConfig, ThunkApiConfig>>, options?: AsyncThunkOptions<ThunkArg, OverrideThunkApiConfigs<CurriedThunkApiConfig, ThunkApiConfig>>): AsyncThunk<Returned, ThunkArg, OverrideThunkApiConfigs<CurriedThunkApiConfig, ThunkApiConfig>>;
|
|
1012
995
|
};
|
|
1013
996
|
type CreateAsyncThunk<CurriedThunkApiConfig extends AsyncThunkConfig> = CreateAsyncThunkFunction<CurriedThunkApiConfig> & {
|
|
1014
|
-
|
|
997
|
+
withTypes<ThunkApiConfig extends AsyncThunkConfig>(): CreateAsyncThunk<OverrideThunkApiConfigs<CurriedThunkApiConfig, ThunkApiConfig>>;
|
|
1015
998
|
};
|
|
1016
999
|
declare const createAsyncThunk: CreateAsyncThunk<AsyncThunkConfig>;
|
|
1017
1000
|
interface UnwrappableAction {
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1001
|
+
payload: any;
|
|
1002
|
+
meta?: any;
|
|
1003
|
+
error?: any;
|
|
1021
1004
|
}
|
|
1022
1005
|
type UnwrappedActionPayload<T extends UnwrappableAction> = Exclude<T, {
|
|
1023
|
-
|
|
1006
|
+
error: any;
|
|
1024
1007
|
}>['payload'];
|
|
1025
1008
|
/**
|
|
1026
1009
|
* @public
|
|
1027
1010
|
*/
|
|
1028
1011
|
declare function unwrapResult<R extends UnwrappableAction>(action: R): UnwrappedActionPayload<R>;
|
|
1029
1012
|
type WithStrictNullChecks<True, False> = undefined extends boolean ? False : True;
|
|
1030
|
-
|
|
1013
|
+
//#endregion
|
|
1014
|
+
//#region src/mapBuilders.d.ts
|
|
1031
1015
|
type AsyncThunkReducers<State, ThunkArg extends any, Returned = unknown, ThunkApiConfig extends AsyncThunkConfig = {}> = {
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1016
|
+
pending?: CaseReducer<State, ReturnType<AsyncThunk<Returned, ThunkArg, ThunkApiConfig>['pending']>>;
|
|
1017
|
+
rejected?: CaseReducer<State, ReturnType<AsyncThunk<Returned, ThunkArg, ThunkApiConfig>['rejected']>>;
|
|
1018
|
+
fulfilled?: CaseReducer<State, ReturnType<AsyncThunk<Returned, ThunkArg, ThunkApiConfig>['fulfilled']>>;
|
|
1019
|
+
settled?: CaseReducer<State, ReturnType<AsyncThunk<Returned, ThunkArg, ThunkApiConfig>['rejected' | 'fulfilled']>>;
|
|
1036
1020
|
};
|
|
1037
1021
|
type TypedActionCreator<Type extends string> = {
|
|
1038
|
-
|
|
1039
|
-
|
|
1022
|
+
(...args: any[]): Action<Type>;
|
|
1023
|
+
type: Type;
|
|
1040
1024
|
};
|
|
1041
1025
|
/**
|
|
1042
1026
|
* A builder for an action <-> reducer map.
|
|
@@ -1044,133 +1028,134 @@ type TypedActionCreator<Type extends string> = {
|
|
|
1044
1028
|
* @public
|
|
1045
1029
|
*/
|
|
1046
1030
|
interface ActionReducerMapBuilder<State> {
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1031
|
+
/**
|
|
1032
|
+
* Adds a case reducer to handle a single exact action type.
|
|
1033
|
+
* @remarks
|
|
1034
|
+
* All calls to `builder.addCase` must come before any calls to `builder.addMatcher` or `builder.addDefaultCase`.
|
|
1035
|
+
* @param actionCreator - Either a plain action type string, or an action creator generated by [`createAction`](./createAction) that can be used to determine the action type.
|
|
1036
|
+
* @param reducer - The actual case reducer function.
|
|
1037
|
+
*/
|
|
1038
|
+
addCase<ActionCreator extends TypedActionCreator<string>>(actionCreator: ActionCreator, reducer: CaseReducer<State, ReturnType<ActionCreator>>): ActionReducerMapBuilder<State>;
|
|
1039
|
+
/**
|
|
1040
|
+
* Adds a case reducer to handle a single exact action type.
|
|
1041
|
+
* @remarks
|
|
1042
|
+
* All calls to `builder.addCase` must come before any calls to `builder.addAsyncThunk`, `builder.addMatcher` or `builder.addDefaultCase`.
|
|
1043
|
+
* @param actionCreator - Either a plain action type string, or an action creator generated by [`createAction`](./createAction) that can be used to determine the action type.
|
|
1044
|
+
* @param reducer - The actual case reducer function.
|
|
1045
|
+
*/
|
|
1046
|
+
addCase<Type extends string, A extends Action<Type>>(type: Type, reducer: CaseReducer<State, A>): ActionReducerMapBuilder<State>;
|
|
1047
|
+
/**
|
|
1048
|
+
* Adds case reducers to handle actions based on a `AsyncThunk` action creator.
|
|
1049
|
+
* @remarks
|
|
1050
|
+
* All calls to `builder.addAsyncThunk` must come before after any calls to `builder.addCase` and before any calls to `builder.addMatcher` or `builder.addDefaultCase`.
|
|
1051
|
+
* @param asyncThunk - The async thunk action creator itself.
|
|
1052
|
+
* @param reducers - A mapping from each of the `AsyncThunk` action types to the case reducer that should handle those actions.
|
|
1053
|
+
* @example
|
|
1054
|
+
* ```ts no-transpile
|
|
1055
|
+
* import { createAsyncThunk, createReducer } from '@reduxjs/toolkit';
|
|
1056
|
+
*
|
|
1057
|
+
* const fetchUserById = createAsyncThunk('users/fetchUser', async (id) => {
|
|
1058
|
+
* const response = await fetch(`https://reqres.in/api/users/${id}`);
|
|
1059
|
+
* return (await response.json()).data;
|
|
1060
|
+
* });
|
|
1061
|
+
*
|
|
1062
|
+
* const reducer = createReducer(initialState, (builder) => {
|
|
1063
|
+
* builder.addAsyncThunk(fetchUserById, {
|
|
1064
|
+
* pending: (state, action) => {
|
|
1065
|
+
* state.fetchUserById.loading = 'pending';
|
|
1066
|
+
* },
|
|
1067
|
+
* fulfilled: (state, action) => {
|
|
1068
|
+
* state.fetchUserById.data = action.payload;
|
|
1069
|
+
* },
|
|
1070
|
+
* rejected: (state, action) => {
|
|
1071
|
+
* state.fetchUserById.error = action.error;
|
|
1072
|
+
* },
|
|
1073
|
+
* settled: (state, action) => {
|
|
1074
|
+
* state.fetchUserById.loading = action.meta.requestStatus;
|
|
1075
|
+
* },
|
|
1076
|
+
* });
|
|
1077
|
+
* });
|
|
1078
|
+
* ```
|
|
1079
|
+
*/
|
|
1080
|
+
addAsyncThunk<Returned, ThunkArg, ThunkApiConfig extends AsyncThunkConfig = {}>(asyncThunk: AsyncThunk<Returned, ThunkArg, ThunkApiConfig>, reducers: AsyncThunkReducers<State, ThunkArg, Returned, ThunkApiConfig>): Omit<ActionReducerMapBuilder<State>, 'addCase'>;
|
|
1081
|
+
/**
|
|
1082
|
+
* Allows you to match your incoming actions against your own filter function instead of only the `action.type` property.
|
|
1083
|
+
* @remarks
|
|
1084
|
+
* If multiple matcher reducers match, all of them will be executed in the order
|
|
1085
|
+
* they were defined in - even if a case reducer already matched.
|
|
1086
|
+
* All calls to `builder.addMatcher` must come after any calls to `builder.addCase` and `builder.addAsyncThunk` and before any calls to `builder.addDefaultCase`.
|
|
1087
|
+
* @param matcher - A matcher function. In TypeScript, this should be a [type predicate](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates)
|
|
1088
|
+
* function
|
|
1089
|
+
* @param reducer - The actual case reducer function.
|
|
1090
|
+
*
|
|
1091
|
+
* @example
|
|
1092
|
+
* ```ts
|
|
1093
|
+
* import type { AsyncThunk, UnknownAction } from '@reduxjs/toolkit';
|
|
1094
|
+
* import { createAction, createReducer } from '@reduxjs/toolkit';
|
|
1095
|
+
*
|
|
1096
|
+
* type GenericAsyncThunk = AsyncThunk<unknown, unknown, any>;
|
|
1097
|
+
*
|
|
1098
|
+
* type PendingAction = ReturnType<GenericAsyncThunk['pending']>;
|
|
1099
|
+
* type RejectedAction = ReturnType<GenericAsyncThunk['rejected']>;
|
|
1100
|
+
* type FulfilledAction = ReturnType<GenericAsyncThunk['fulfilled']>;
|
|
1101
|
+
*
|
|
1102
|
+
* const initialState: Record<string, string> = {};
|
|
1103
|
+
* const resetAction = createAction('reset-tracked-loading-state');
|
|
1104
|
+
*
|
|
1105
|
+
* function isPendingAction(action: UnknownAction): action is PendingAction {
|
|
1106
|
+
* return typeof action.type === 'string' && action.type.endsWith('/pending');
|
|
1107
|
+
* }
|
|
1108
|
+
*
|
|
1109
|
+
* const reducer = createReducer(initialState, (builder) => {
|
|
1110
|
+
* builder
|
|
1111
|
+
* .addCase(resetAction, () => initialState)
|
|
1112
|
+
* // matcher can be defined outside as a type predicate function
|
|
1113
|
+
* .addMatcher(isPendingAction, (state, action) => {
|
|
1114
|
+
* state[action.meta.requestId] = 'pending';
|
|
1115
|
+
* })
|
|
1116
|
+
* .addMatcher(
|
|
1117
|
+
* // matcher can be defined inline as a type predicate function
|
|
1118
|
+
* (action): action is RejectedAction => action.type.endsWith('/rejected'),
|
|
1119
|
+
* (state, action) => {
|
|
1120
|
+
* state[action.meta.requestId] = 'rejected';
|
|
1121
|
+
* },
|
|
1122
|
+
* )
|
|
1123
|
+
* // matcher can just return boolean and the matcher can receive a generic argument
|
|
1124
|
+
* .addMatcher<FulfilledAction>(
|
|
1125
|
+
* (action) => action.type.endsWith('/fulfilled'),
|
|
1126
|
+
* (state, action) => {
|
|
1127
|
+
* state[action.meta.requestId] = 'fulfilled';
|
|
1128
|
+
* },
|
|
1129
|
+
* );
|
|
1130
|
+
* });
|
|
1131
|
+
* ```
|
|
1132
|
+
*/
|
|
1133
|
+
addMatcher<A>(matcher: TypeGuard<A> | ((action: any) => boolean), reducer: CaseReducer<State, A extends Action ? A : A & Action>): Omit<ActionReducerMapBuilder<State>, 'addCase' | 'addAsyncThunk'>;
|
|
1134
|
+
/**
|
|
1135
|
+
* Adds a "default case" reducer that is executed if no case reducer and no matcher
|
|
1136
|
+
* reducer was executed for this action.
|
|
1137
|
+
* @param reducer - The fallback "default case" reducer function.
|
|
1138
|
+
*
|
|
1139
|
+
* @example
|
|
1140
|
+
* ```ts
|
|
1141
|
+
* import { createReducer } from '@reduxjs/toolkit';
|
|
1142
|
+
*
|
|
1143
|
+
* const initialState = { otherActions: 0 };
|
|
1144
|
+
*
|
|
1145
|
+
* const reducer = createReducer(initialState, (builder) => {
|
|
1146
|
+
* builder
|
|
1147
|
+
* // .addCase(...)
|
|
1148
|
+
* // .addMatcher(...)
|
|
1149
|
+
* .addDefaultCase((state, action) => {
|
|
1150
|
+
* state.otherActions++;
|
|
1151
|
+
* });
|
|
1152
|
+
* });
|
|
1153
|
+
* ```
|
|
1154
|
+
*/
|
|
1155
|
+
addDefaultCase(reducer: CaseReducer<State, Action>): {};
|
|
1172
1156
|
}
|
|
1173
|
-
|
|
1157
|
+
//#endregion
|
|
1158
|
+
//#region src/createReducer.d.ts
|
|
1174
1159
|
/**
|
|
1175
1160
|
* Defines a mapping from action types to corresponding action object shapes.
|
|
1176
1161
|
*
|
|
@@ -1196,7 +1181,7 @@ type Actions<T extends keyof any = string> = Record<T, Action>;
|
|
|
1196
1181
|
*
|
|
1197
1182
|
* @public
|
|
1198
1183
|
*/
|
|
1199
|
-
type CaseReducer<S = any, A extends Action = UnknownAction> = (state: Draft<S>, action: A) => NoInfer<S> | void | Draft<NoInfer<S>>;
|
|
1184
|
+
type CaseReducer<S = any, A extends Action = UnknownAction> = (state: Draft$1<S>, action: A) => NoInfer<S> | void | Draft$1<NoInfer<S>>;
|
|
1200
1185
|
/**
|
|
1201
1186
|
* A mapping from action types to case reducers for `createReducer()`.
|
|
1202
1187
|
*
|
|
@@ -1206,12 +1191,10 @@ type CaseReducer<S = any, A extends Action = UnknownAction> = (state: Draft<S>,
|
|
|
1206
1191
|
* It might be removed in the future.
|
|
1207
1192
|
* @public
|
|
1208
1193
|
*/
|
|
1209
|
-
type CaseReducers<S, AS extends Actions> = {
|
|
1210
|
-
[T in keyof AS]: AS[T] extends Action ? CaseReducer<S, AS[T]> : void;
|
|
1211
|
-
};
|
|
1194
|
+
type CaseReducers<S, AS extends Actions> = { [T in keyof AS]: AS[T] extends Action ? CaseReducer<S, AS[T]> : void; };
|
|
1212
1195
|
type NotFunction<T> = T extends Function ? never : T;
|
|
1213
1196
|
type ReducerWithInitialState<S extends NotFunction<any>> = Reducer<S> & {
|
|
1214
|
-
|
|
1197
|
+
getInitialState: () => S;
|
|
1215
1198
|
};
|
|
1216
1199
|
/**
|
|
1217
1200
|
* A utility function that allows defining a reducer as a mapping from action
|
|
@@ -1274,91 +1257,166 @@ type ReducerWithInitialState<S extends NotFunction<any>> = Reducer<S> & {
|
|
|
1274
1257
|
* @public
|
|
1275
1258
|
*/
|
|
1276
1259
|
declare function createReducer<S extends NotFunction<any>>(initialState: S | (() => S), mapOrBuilderCallback: (builder: ActionReducerMapBuilder<S>) => void): ReducerWithInitialState<S>;
|
|
1277
|
-
|
|
1260
|
+
//#endregion
|
|
1261
|
+
//#region src/combineSlices.d.ts
|
|
1278
1262
|
type SliceLike<ReducerPath extends string, State, PreloadedState = State> = {
|
|
1279
|
-
|
|
1280
|
-
|
|
1263
|
+
reducerPath: ReducerPath;
|
|
1264
|
+
reducer: Reducer<State, any, PreloadedState>;
|
|
1281
1265
|
};
|
|
1282
1266
|
type AnySliceLike = SliceLike<string, any>;
|
|
1283
1267
|
type SliceLikeReducerPath<A extends AnySliceLike> = A extends SliceLike<infer ReducerPath, any> ? ReducerPath : never;
|
|
1284
1268
|
type SliceLikeState<A extends AnySliceLike> = A extends SliceLike<any, infer State, any> ? State : never;
|
|
1285
1269
|
type SliceLikePreloadedState<A extends AnySliceLike> = A extends SliceLike<any, any, infer PreloadedState> ? PreloadedState : never;
|
|
1286
|
-
type WithSlice<A extends AnySliceLike> = {
|
|
1287
|
-
|
|
1288
|
-
};
|
|
1289
|
-
type WithSlicePreloadedState<A extends AnySliceLike> = {
|
|
1290
|
-
[Path in SliceLikeReducerPath<A>]: SliceLikePreloadedState<A>;
|
|
1291
|
-
};
|
|
1270
|
+
type WithSlice<A extends AnySliceLike> = { [Path in SliceLikeReducerPath<A>]: SliceLikeState<A>; };
|
|
1271
|
+
type WithSlicePreloadedState<A extends AnySliceLike> = { [Path in SliceLikeReducerPath<A>]: SliceLikePreloadedState<A>; };
|
|
1292
1272
|
type ReducerMap = Record<string, Reducer>;
|
|
1293
|
-
type ExistingSliceLike<DeclaredState, PreloadedState> = {
|
|
1294
|
-
[ReducerPath in keyof DeclaredState]: SliceLike<ReducerPath & string, NonUndefined<DeclaredState[ReducerPath]>, NonUndefined<PreloadedState[ReducerPath & keyof PreloadedState]>>;
|
|
1295
|
-
}[keyof DeclaredState];
|
|
1273
|
+
type ExistingSliceLike<DeclaredState, PreloadedState> = { [ReducerPath in keyof DeclaredState]: SliceLike<ReducerPath & string, NonUndefined<DeclaredState[ReducerPath]>, NonUndefined<PreloadedState[ReducerPath & keyof PreloadedState]>>; }[keyof DeclaredState];
|
|
1296
1274
|
type InjectConfig = {
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1275
|
+
/**
|
|
1276
|
+
* Allow replacing reducer with a different reference. Normally, an error will be thrown if a different reducer instance to the one already injected is used.
|
|
1277
|
+
*/
|
|
1278
|
+
overrideExisting?: boolean;
|
|
1301
1279
|
};
|
|
1302
1280
|
/**
|
|
1303
1281
|
* A reducer that allows for slices/reducers to be injected after initialisation.
|
|
1304
1282
|
*/
|
|
1305
1283
|
interface CombinedSliceReducer<InitialState, DeclaredState extends InitialState = InitialState, PreloadedState extends Partial<Record<keyof PreloadedState, any>> = Partial<DeclaredState>> extends Reducer<DeclaredState, UnknownAction, PreloadedState> {
|
|
1284
|
+
/**
|
|
1285
|
+
* Provide a type for slices that will be injected lazily.
|
|
1286
|
+
*
|
|
1287
|
+
* One way to do this would be with interface merging:
|
|
1288
|
+
* ```ts
|
|
1289
|
+
*
|
|
1290
|
+
* export interface LazyLoadedSlices {}
|
|
1291
|
+
*
|
|
1292
|
+
* export const rootReducer = combineSlices(stringSlice).withLazyLoadedSlices<LazyLoadedSlices>();
|
|
1293
|
+
*
|
|
1294
|
+
* // elsewhere
|
|
1295
|
+
*
|
|
1296
|
+
* declare module './reducer' {
|
|
1297
|
+
* export interface LazyLoadedSlices extends WithSlice<typeof booleanSlice> {}
|
|
1298
|
+
* }
|
|
1299
|
+
*
|
|
1300
|
+
* const withBoolean = rootReducer.inject(booleanSlice);
|
|
1301
|
+
*
|
|
1302
|
+
* // elsewhere again
|
|
1303
|
+
*
|
|
1304
|
+
* declare module './reducer' {
|
|
1305
|
+
* export interface LazyLoadedSlices {
|
|
1306
|
+
* customName: CustomState
|
|
1307
|
+
* }
|
|
1308
|
+
* }
|
|
1309
|
+
*
|
|
1310
|
+
* const withCustom = rootReducer.inject({ reducerPath: "customName", reducer: customSlice.reducer })
|
|
1311
|
+
* ```
|
|
1312
|
+
*/
|
|
1313
|
+
withLazyLoadedSlices<Lazy = {}, LazyPreloaded = Lazy>(): CombinedSliceReducer<InitialState, Id<DeclaredState & Partial<Lazy>>, Id<PreloadedState & Partial<LazyPreloaded>>>;
|
|
1314
|
+
/**
|
|
1315
|
+
* Inject a slice.
|
|
1316
|
+
*
|
|
1317
|
+
* Accepts an individual slice, RTKQ API instance, or a "slice-like" { reducerPath, reducer } object.
|
|
1318
|
+
*
|
|
1319
|
+
* ```ts
|
|
1320
|
+
* rootReducer.inject(booleanSlice)
|
|
1321
|
+
* rootReducer.inject(baseApi)
|
|
1322
|
+
* rootReducer.inject({ reducerPath: 'boolean' as const, reducer: newReducer }, { overrideExisting: true })
|
|
1323
|
+
* ```
|
|
1324
|
+
*
|
|
1325
|
+
*/
|
|
1326
|
+
inject<Sl extends Id<ExistingSliceLike<DeclaredState, PreloadedState>>>(slice: Sl, config?: InjectConfig): CombinedSliceReducer<InitialState, Id<DeclaredState & WithSlice<Sl>>, Id<PreloadedState & Partial<WithSlicePreloadedState<Sl>>>>;
|
|
1327
|
+
/**
|
|
1328
|
+
* Inject a slice.
|
|
1329
|
+
*
|
|
1330
|
+
* Accepts an individual slice, RTKQ API instance, or a "slice-like" { reducerPath, reducer } object.
|
|
1331
|
+
*
|
|
1332
|
+
* ```ts
|
|
1333
|
+
* rootReducer.inject(booleanSlice)
|
|
1334
|
+
* rootReducer.inject(baseApi)
|
|
1335
|
+
* rootReducer.inject({ reducerPath: 'boolean' as const, reducer: newReducer }, { overrideExisting: true })
|
|
1336
|
+
* ```
|
|
1337
|
+
*
|
|
1338
|
+
*/
|
|
1339
|
+
inject<ReducerPath extends string, State, PreloadedState = State>(slice: SliceLike<ReducerPath, State & (ReducerPath extends keyof DeclaredState ? never : State), PreloadedState & (ReducerPath extends keyof PreloadedState ? never : PreloadedState)>, config?: InjectConfig): CombinedSliceReducer<InitialState, Id<DeclaredState & WithSlice<SliceLike<ReducerPath, State>>>, Id<PreloadedState & WithSlicePreloadedState<SliceLike<ReducerPath, State, PreloadedState>>>>;
|
|
1340
|
+
/**
|
|
1341
|
+
* Create a selector that guarantees that the slices injected will have a defined value when selector is run.
|
|
1342
|
+
*
|
|
1343
|
+
* ```ts
|
|
1344
|
+
* const selectBooleanWithoutInjection = (state: RootState) => state.boolean;
|
|
1345
|
+
* // ^? boolean | undefined
|
|
1346
|
+
*
|
|
1347
|
+
* const selectBoolean = rootReducer.inject(booleanSlice).selector((state) => {
|
|
1348
|
+
* // if action hasn't been dispatched since slice was injected, this would usually be undefined
|
|
1349
|
+
* // however selector() uses a Proxy around the first parameter to ensure that it evaluates to the initial state instead, if undefined
|
|
1350
|
+
* return state.boolean;
|
|
1351
|
+
* // ^? boolean
|
|
1352
|
+
* })
|
|
1353
|
+
* ```
|
|
1354
|
+
*
|
|
1355
|
+
* If the reducer is nested inside the root state, a selectState callback can be passed to retrieve the reducer's state.
|
|
1356
|
+
*
|
|
1357
|
+
* ```ts
|
|
1358
|
+
*
|
|
1359
|
+
* export interface LazyLoadedSlices {};
|
|
1360
|
+
*
|
|
1361
|
+
* export const innerReducer = combineSlices(stringSlice).withLazyLoadedSlices<LazyLoadedSlices>();
|
|
1362
|
+
*
|
|
1363
|
+
* export const rootReducer = combineSlices({ inner: innerReducer });
|
|
1364
|
+
*
|
|
1365
|
+
* export type RootState = ReturnType<typeof rootReducer>;
|
|
1366
|
+
*
|
|
1367
|
+
* // elsewhere
|
|
1368
|
+
*
|
|
1369
|
+
* declare module "./reducer.ts" {
|
|
1370
|
+
* export interface LazyLoadedSlices extends WithSlice<typeof booleanSlice> {}
|
|
1371
|
+
* }
|
|
1372
|
+
*
|
|
1373
|
+
* const withBool = innerReducer.inject(booleanSlice);
|
|
1374
|
+
*
|
|
1375
|
+
* const selectBoolean = withBool.selector(
|
|
1376
|
+
* (state) => state.boolean,
|
|
1377
|
+
* (rootState: RootState) => state.inner
|
|
1378
|
+
* );
|
|
1379
|
+
* // now expects to be passed RootState instead of innerReducer state
|
|
1380
|
+
*
|
|
1381
|
+
* ```
|
|
1382
|
+
*
|
|
1383
|
+
* Value passed to selectorFn will be a Proxy - use selector.original(proxy) to get original state value (useful for debugging)
|
|
1384
|
+
*
|
|
1385
|
+
* ```ts
|
|
1386
|
+
* const injectedReducer = rootReducer.inject(booleanSlice);
|
|
1387
|
+
* const selectBoolean = injectedReducer.selector((state) => {
|
|
1388
|
+
* console.log(injectedReducer.selector.original(state).boolean) // possibly undefined
|
|
1389
|
+
* return state.boolean
|
|
1390
|
+
* })
|
|
1391
|
+
* ```
|
|
1392
|
+
*/
|
|
1393
|
+
selector: {
|
|
1306
1394
|
/**
|
|
1307
|
-
*
|
|
1395
|
+
* Create a selector that guarantees that the slices injected will have a defined value when selector is run.
|
|
1308
1396
|
*
|
|
1309
|
-
* One way to do this would be with interface merging:
|
|
1310
1397
|
* ```ts
|
|
1398
|
+
* const selectBooleanWithoutInjection = (state: RootState) => state.boolean;
|
|
1399
|
+
* // ^? boolean | undefined
|
|
1311
1400
|
*
|
|
1312
|
-
*
|
|
1313
|
-
*
|
|
1314
|
-
*
|
|
1315
|
-
*
|
|
1316
|
-
*
|
|
1317
|
-
*
|
|
1318
|
-
* declare module './reducer' {
|
|
1319
|
-
* export interface LazyLoadedSlices extends WithSlice<typeof booleanSlice> {}
|
|
1320
|
-
* }
|
|
1321
|
-
*
|
|
1322
|
-
* const withBoolean = rootReducer.inject(booleanSlice);
|
|
1323
|
-
*
|
|
1324
|
-
* // elsewhere again
|
|
1325
|
-
*
|
|
1326
|
-
* declare module './reducer' {
|
|
1327
|
-
* export interface LazyLoadedSlices {
|
|
1328
|
-
* customName: CustomState
|
|
1329
|
-
* }
|
|
1330
|
-
* }
|
|
1331
|
-
*
|
|
1332
|
-
* const withCustom = rootReducer.inject({ reducerPath: "customName", reducer: customSlice.reducer })
|
|
1333
|
-
* ```
|
|
1334
|
-
*/
|
|
1335
|
-
withLazyLoadedSlices<Lazy = {}, LazyPreloaded = Lazy>(): CombinedSliceReducer<InitialState, Id<DeclaredState & Partial<Lazy>>, Id<PreloadedState & Partial<LazyPreloaded>>>;
|
|
1336
|
-
/**
|
|
1337
|
-
* Inject a slice.
|
|
1338
|
-
*
|
|
1339
|
-
* Accepts an individual slice, RTKQ API instance, or a "slice-like" { reducerPath, reducer } object.
|
|
1340
|
-
*
|
|
1341
|
-
* ```ts
|
|
1342
|
-
* rootReducer.inject(booleanSlice)
|
|
1343
|
-
* rootReducer.inject(baseApi)
|
|
1344
|
-
* rootReducer.inject({ reducerPath: 'boolean' as const, reducer: newReducer }, { overrideExisting: true })
|
|
1401
|
+
* const selectBoolean = rootReducer.inject(booleanSlice).selector((state) => {
|
|
1402
|
+
* // if action hasn't been dispatched since slice was injected, this would usually be undefined
|
|
1403
|
+
* // however selector() uses a Proxy around the first parameter to ensure that it evaluates to the initial state instead, if undefined
|
|
1404
|
+
* return state.boolean;
|
|
1405
|
+
* // ^? boolean
|
|
1406
|
+
* })
|
|
1345
1407
|
* ```
|
|
1346
1408
|
*
|
|
1347
|
-
|
|
1348
|
-
inject<Sl extends Id<ExistingSliceLike<DeclaredState, PreloadedState>>>(slice: Sl, config?: InjectConfig): CombinedSliceReducer<InitialState, Id<DeclaredState & WithSlice<Sl>>, Id<PreloadedState & Partial<WithSlicePreloadedState<Sl>>>>;
|
|
1349
|
-
/**
|
|
1350
|
-
* Inject a slice.
|
|
1351
|
-
*
|
|
1352
|
-
* Accepts an individual slice, RTKQ API instance, or a "slice-like" { reducerPath, reducer } object.
|
|
1409
|
+
* Value passed to selectorFn will be a Proxy - use selector.original(proxy) to get original state value (useful for debugging)
|
|
1353
1410
|
*
|
|
1354
1411
|
* ```ts
|
|
1355
|
-
* rootReducer.inject(booleanSlice)
|
|
1356
|
-
*
|
|
1357
|
-
*
|
|
1412
|
+
* const injectedReducer = rootReducer.inject(booleanSlice);
|
|
1413
|
+
* const selectBoolean = injectedReducer.selector((state) => {
|
|
1414
|
+
* console.log(injectedReducer.selector.original(state).boolean) // undefined
|
|
1415
|
+
* return state.boolean
|
|
1416
|
+
* })
|
|
1358
1417
|
* ```
|
|
1359
|
-
*
|
|
1360
1418
|
*/
|
|
1361
|
-
|
|
1419
|
+
<Selector extends (state: DeclaredState, ...args: any[]) => unknown>(selectorFn: Selector): (state: WithOptionalProp<Parameters<Selector>[0], Exclude<keyof DeclaredState, keyof InitialState>>, ...args: Tail<Parameters<Selector>>) => ReturnType<Selector>;
|
|
1362
1420
|
/**
|
|
1363
1421
|
* Create a selector that guarantees that the slices injected will have a defined value when selector is run.
|
|
1364
1422
|
*
|
|
@@ -1378,18 +1436,18 @@ interface CombinedSliceReducer<InitialState, DeclaredState extends InitialState
|
|
|
1378
1436
|
*
|
|
1379
1437
|
* ```ts
|
|
1380
1438
|
*
|
|
1381
|
-
*
|
|
1439
|
+
* interface LazyLoadedSlices {};
|
|
1382
1440
|
*
|
|
1383
|
-
*
|
|
1441
|
+
* const innerReducer = combineSlices(stringSlice).withLazyLoadedSlices<LazyLoadedSlices>();
|
|
1384
1442
|
*
|
|
1385
|
-
*
|
|
1443
|
+
* const rootReducer = combineSlices({ inner: innerReducer });
|
|
1386
1444
|
*
|
|
1387
|
-
*
|
|
1445
|
+
* type RootState = ReturnType<typeof rootReducer>;
|
|
1388
1446
|
*
|
|
1389
1447
|
* // elsewhere
|
|
1390
1448
|
*
|
|
1391
1449
|
* declare module "./reducer.ts" {
|
|
1392
|
-
*
|
|
1450
|
+
* interface LazyLoadedSlices extends WithSlice<typeof booleanSlice> {}
|
|
1393
1451
|
* }
|
|
1394
1452
|
*
|
|
1395
1453
|
* const withBool = innerReducer.inject(booleanSlice);
|
|
@@ -1412,204 +1470,117 @@ interface CombinedSliceReducer<InitialState, DeclaredState extends InitialState
|
|
|
1412
1470
|
* })
|
|
1413
1471
|
* ```
|
|
1414
1472
|
*/
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
* // if action hasn't been dispatched since slice was injected, this would usually be undefined
|
|
1425
|
-
* // however selector() uses a Proxy around the first parameter to ensure that it evaluates to the initial state instead, if undefined
|
|
1426
|
-
* return state.boolean;
|
|
1427
|
-
* // ^? boolean
|
|
1428
|
-
* })
|
|
1429
|
-
* ```
|
|
1430
|
-
*
|
|
1431
|
-
* Value passed to selectorFn will be a Proxy - use selector.original(proxy) to get original state value (useful for debugging)
|
|
1432
|
-
*
|
|
1433
|
-
* ```ts
|
|
1434
|
-
* const injectedReducer = rootReducer.inject(booleanSlice);
|
|
1435
|
-
* const selectBoolean = injectedReducer.selector((state) => {
|
|
1436
|
-
* console.log(injectedReducer.selector.original(state).boolean) // undefined
|
|
1437
|
-
* return state.boolean
|
|
1438
|
-
* })
|
|
1439
|
-
* ```
|
|
1440
|
-
*/
|
|
1441
|
-
<Selector extends (state: DeclaredState, ...args: any[]) => unknown>(selectorFn: Selector): (state: WithOptionalProp<Parameters<Selector>[0], Exclude<keyof DeclaredState, keyof InitialState>>, ...args: Tail<Parameters<Selector>>) => ReturnType<Selector>;
|
|
1442
|
-
/**
|
|
1443
|
-
* Create a selector that guarantees that the slices injected will have a defined value when selector is run.
|
|
1444
|
-
*
|
|
1445
|
-
* ```ts
|
|
1446
|
-
* const selectBooleanWithoutInjection = (state: RootState) => state.boolean;
|
|
1447
|
-
* // ^? boolean | undefined
|
|
1448
|
-
*
|
|
1449
|
-
* const selectBoolean = rootReducer.inject(booleanSlice).selector((state) => {
|
|
1450
|
-
* // if action hasn't been dispatched since slice was injected, this would usually be undefined
|
|
1451
|
-
* // however selector() uses a Proxy around the first parameter to ensure that it evaluates to the initial state instead, if undefined
|
|
1452
|
-
* return state.boolean;
|
|
1453
|
-
* // ^? boolean
|
|
1454
|
-
* })
|
|
1455
|
-
* ```
|
|
1456
|
-
*
|
|
1457
|
-
* If the reducer is nested inside the root state, a selectState callback can be passed to retrieve the reducer's state.
|
|
1458
|
-
*
|
|
1459
|
-
* ```ts
|
|
1460
|
-
*
|
|
1461
|
-
* interface LazyLoadedSlices {};
|
|
1462
|
-
*
|
|
1463
|
-
* const innerReducer = combineSlices(stringSlice).withLazyLoadedSlices<LazyLoadedSlices>();
|
|
1464
|
-
*
|
|
1465
|
-
* const rootReducer = combineSlices({ inner: innerReducer });
|
|
1466
|
-
*
|
|
1467
|
-
* type RootState = ReturnType<typeof rootReducer>;
|
|
1468
|
-
*
|
|
1469
|
-
* // elsewhere
|
|
1470
|
-
*
|
|
1471
|
-
* declare module "./reducer.ts" {
|
|
1472
|
-
* interface LazyLoadedSlices extends WithSlice<typeof booleanSlice> {}
|
|
1473
|
-
* }
|
|
1474
|
-
*
|
|
1475
|
-
* const withBool = innerReducer.inject(booleanSlice);
|
|
1476
|
-
*
|
|
1477
|
-
* const selectBoolean = withBool.selector(
|
|
1478
|
-
* (state) => state.boolean,
|
|
1479
|
-
* (rootState: RootState) => state.inner
|
|
1480
|
-
* );
|
|
1481
|
-
* // now expects to be passed RootState instead of innerReducer state
|
|
1482
|
-
*
|
|
1483
|
-
* ```
|
|
1484
|
-
*
|
|
1485
|
-
* Value passed to selectorFn will be a Proxy - use selector.original(proxy) to get original state value (useful for debugging)
|
|
1486
|
-
*
|
|
1487
|
-
* ```ts
|
|
1488
|
-
* const injectedReducer = rootReducer.inject(booleanSlice);
|
|
1489
|
-
* const selectBoolean = injectedReducer.selector((state) => {
|
|
1490
|
-
* console.log(injectedReducer.selector.original(state).boolean) // possibly undefined
|
|
1491
|
-
* return state.boolean
|
|
1492
|
-
* })
|
|
1493
|
-
* ```
|
|
1494
|
-
*/
|
|
1495
|
-
<Selector extends (state: DeclaredState, ...args: any[]) => unknown, RootState>(selectorFn: Selector, selectState: (rootState: RootState, ...args: Tail<Parameters<Selector>>) => WithOptionalProp<Parameters<Selector>[0], Exclude<keyof DeclaredState, keyof InitialState>>): (state: RootState, ...args: Tail<Parameters<Selector>>) => ReturnType<Selector>;
|
|
1496
|
-
/**
|
|
1497
|
-
* Returns the unproxied state. Useful for debugging.
|
|
1498
|
-
* @param state state Proxy, that ensures injected reducers have value
|
|
1499
|
-
* @returns original, unproxied state
|
|
1500
|
-
* @throws if value passed is not a state Proxy
|
|
1501
|
-
*/
|
|
1502
|
-
original: (state: DeclaredState) => InitialState & Partial<DeclaredState>;
|
|
1503
|
-
};
|
|
1473
|
+
<Selector extends (state: DeclaredState, ...args: any[]) => unknown, RootState>(selectorFn: Selector, selectState: (rootState: RootState, ...args: Tail<Parameters<Selector>>) => WithOptionalProp<Parameters<Selector>[0], Exclude<keyof DeclaredState, keyof InitialState>>): (state: RootState, ...args: Tail<Parameters<Selector>>) => ReturnType<Selector>;
|
|
1474
|
+
/**
|
|
1475
|
+
* Returns the unproxied state. Useful for debugging.
|
|
1476
|
+
* @param state state Proxy, that ensures injected reducers have value
|
|
1477
|
+
* @returns original, unproxied state
|
|
1478
|
+
* @throws if value passed is not a state Proxy
|
|
1479
|
+
*/
|
|
1480
|
+
original: (state: DeclaredState) => InitialState & Partial<DeclaredState>;
|
|
1481
|
+
};
|
|
1504
1482
|
}
|
|
1505
|
-
type InitialState<Slices extends Array<AnySliceLike | ReducerMap>> = UnionToIntersection<Slices[number] extends infer Slice ? Slice extends AnySliceLike ? WithSlice<Slice> : StateFromReducersMapObject<Slice> : never>;
|
|
1506
|
-
type InitialPreloadedState<Slices extends Array<AnySliceLike | ReducerMap>> = UnionToIntersection<Slices[number] extends infer Slice ? Slice extends AnySliceLike ? WithSlicePreloadedState<Slice> : PreloadedStateShapeFromReducersMapObject<Slice> : never>;
|
|
1483
|
+
type InitialState<Slices extends Array<AnySliceLike | ReducerMap>> = UnionToIntersection<Slices[number] extends (infer Slice) ? Slice extends AnySliceLike ? WithSlice<Slice> : StateFromReducersMapObject<Slice> : never>;
|
|
1484
|
+
type InitialPreloadedState<Slices extends Array<AnySliceLike | ReducerMap>> = UnionToIntersection<Slices[number] extends (infer Slice) ? Slice extends AnySliceLike ? WithSlicePreloadedState<Slice> : PreloadedStateShapeFromReducersMapObject<Slice> : never>;
|
|
1507
1485
|
declare function combineSlices<Slices extends Array<AnySliceLike | ReducerMap>>(...slices: Slices): CombinedSliceReducer<Id<InitialState<Slices>>, Id<InitialState<Slices>>, Partial<Id<InitialPreloadedState<Slices>>>>;
|
|
1508
|
-
|
|
1486
|
+
//#endregion
|
|
1487
|
+
//#region src/createSlice.d.ts
|
|
1509
1488
|
declare const asyncThunkSymbol: unique symbol;
|
|
1510
1489
|
declare const asyncThunkCreator: {
|
|
1511
|
-
|
|
1490
|
+
[asyncThunkSymbol]: typeof createAsyncThunk;
|
|
1512
1491
|
};
|
|
1513
1492
|
type InjectIntoConfig<NewReducerPath extends string> = InjectConfig & {
|
|
1514
|
-
|
|
1493
|
+
reducerPath?: NewReducerPath;
|
|
1515
1494
|
};
|
|
1516
1495
|
/**
|
|
1517
1496
|
* The return value of `createSlice`
|
|
1518
1497
|
*
|
|
1519
1498
|
* @public
|
|
1520
1499
|
*/
|
|
1521
|
-
interface Slice<State = any, CaseReducers extends SliceCaseReducers<State> = SliceCaseReducers<State>, Name extends string = string, ReducerPath extends string = Name, Selectors extends SliceSelectors<State> = SliceSelectors<State>> {
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
*/
|
|
1579
|
-
selectSlice(state: {
|
|
1580
|
-
[K in ReducerPath]: State;
|
|
1581
|
-
}): State;
|
|
1500
|
+
interface Slice$1<State = any, CaseReducers extends SliceCaseReducers<State> = SliceCaseReducers<State>, Name extends string = string, ReducerPath extends string = Name, Selectors extends SliceSelectors<State> = SliceSelectors<State>> {
|
|
1501
|
+
/**
|
|
1502
|
+
* The slice name.
|
|
1503
|
+
*/
|
|
1504
|
+
name: Name;
|
|
1505
|
+
/**
|
|
1506
|
+
* The slice reducer path.
|
|
1507
|
+
*/
|
|
1508
|
+
reducerPath: ReducerPath;
|
|
1509
|
+
/**
|
|
1510
|
+
* The slice's reducer.
|
|
1511
|
+
*/
|
|
1512
|
+
reducer: Reducer<State>;
|
|
1513
|
+
/**
|
|
1514
|
+
* Action creators for the types of actions that are handled by the slice
|
|
1515
|
+
* reducer.
|
|
1516
|
+
*/
|
|
1517
|
+
actions: CaseReducerActions<CaseReducers, Name>;
|
|
1518
|
+
/**
|
|
1519
|
+
* The individual case reducer functions that were passed in the `reducers` parameter.
|
|
1520
|
+
* This enables reuse and testing if they were defined inline when calling `createSlice`.
|
|
1521
|
+
*/
|
|
1522
|
+
caseReducers: SliceDefinedCaseReducers<CaseReducers>;
|
|
1523
|
+
/**
|
|
1524
|
+
* Provides access to the initial state value given to the slice.
|
|
1525
|
+
* If a lazy state initializer was provided, it will be called and a fresh value returned.
|
|
1526
|
+
*/
|
|
1527
|
+
getInitialState: () => State;
|
|
1528
|
+
/**
|
|
1529
|
+
* Get localised slice selectors (expects to be called with *just* the slice's state as the first parameter)
|
|
1530
|
+
*/
|
|
1531
|
+
getSelectors(): Id<SliceDefinedSelectors<State, Selectors, State>>;
|
|
1532
|
+
/**
|
|
1533
|
+
* Get globalised slice selectors (`selectState` callback is expected to receive first parameter and return slice state)
|
|
1534
|
+
*/
|
|
1535
|
+
getSelectors<RootState>(selectState: (rootState: RootState) => State): Id<SliceDefinedSelectors<State, Selectors, RootState>>;
|
|
1536
|
+
/**
|
|
1537
|
+
* Selectors that assume the slice's state is `rootState[slice.reducerPath]` (which is usually the case)
|
|
1538
|
+
*
|
|
1539
|
+
* Equivalent to `slice.getSelectors((state: RootState) => state[slice.reducerPath])`.
|
|
1540
|
+
*/
|
|
1541
|
+
get selectors(): Id<SliceDefinedSelectors<State, Selectors, { [K in ReducerPath]: State; }>>;
|
|
1542
|
+
/**
|
|
1543
|
+
* Inject slice into provided reducer (return value from `combineSlices`), and return injected slice.
|
|
1544
|
+
*/
|
|
1545
|
+
injectInto<NewReducerPath extends string = ReducerPath>(this: this, injectable: {
|
|
1546
|
+
inject: (slice: {
|
|
1547
|
+
reducerPath: string;
|
|
1548
|
+
reducer: Reducer;
|
|
1549
|
+
}, config?: InjectConfig) => void;
|
|
1550
|
+
}, config?: InjectIntoConfig<NewReducerPath>): InjectedSlice<State, CaseReducers, Name, NewReducerPath, Selectors>;
|
|
1551
|
+
/**
|
|
1552
|
+
* Select the slice state, using the slice's current reducerPath.
|
|
1553
|
+
*
|
|
1554
|
+
* Will throw an error if slice is not found.
|
|
1555
|
+
*/
|
|
1556
|
+
selectSlice(state: { [K in ReducerPath]: State; }): State;
|
|
1582
1557
|
}
|
|
1583
1558
|
/**
|
|
1584
1559
|
* A slice after being called with `injectInto(reducer)`.
|
|
1585
1560
|
*
|
|
1586
1561
|
* Selectors can now be called with an `undefined` value, in which case they use the slice's initial state.
|
|
1587
1562
|
*/
|
|
1588
|
-
type InjectedSlice<State = any, CaseReducers extends SliceCaseReducers<State> = SliceCaseReducers<State>, Name extends string = string, ReducerPath extends string = Name, Selectors extends SliceSelectors<State> = SliceSelectors<State>> = Omit<Slice<State, CaseReducers, Name, ReducerPath, Selectors>, 'getSelectors' | 'selectors'> & {
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
*/
|
|
1610
|
-
selectSlice(state: {
|
|
1611
|
-
[K in ReducerPath]?: State | undefined;
|
|
1612
|
-
}): State;
|
|
1563
|
+
type InjectedSlice<State = any, CaseReducers extends SliceCaseReducers<State> = SliceCaseReducers<State>, Name extends string = string, ReducerPath extends string = Name, Selectors extends SliceSelectors<State> = SliceSelectors<State>> = Omit<Slice$1<State, CaseReducers, Name, ReducerPath, Selectors>, 'getSelectors' | 'selectors'> & {
|
|
1564
|
+
/**
|
|
1565
|
+
* Get localised slice selectors (expects to be called with *just* the slice's state as the first parameter)
|
|
1566
|
+
*/
|
|
1567
|
+
getSelectors(): Id<SliceDefinedSelectors<State, Selectors, State | undefined>>;
|
|
1568
|
+
/**
|
|
1569
|
+
* Get globalised slice selectors (`selectState` callback is expected to receive first parameter and return slice state)
|
|
1570
|
+
*/
|
|
1571
|
+
getSelectors<RootState>(selectState: (rootState: RootState) => State | undefined): Id<SliceDefinedSelectors<State, Selectors, RootState>>;
|
|
1572
|
+
/**
|
|
1573
|
+
* Selectors that assume the slice's state is `rootState[slice.name]` (which is usually the case)
|
|
1574
|
+
*
|
|
1575
|
+
* Equivalent to `slice.getSelectors((state: RootState) => state[slice.name])`.
|
|
1576
|
+
*/
|
|
1577
|
+
get selectors(): Id<SliceDefinedSelectors<State, Selectors, { [K in ReducerPath]?: State | undefined; }>>;
|
|
1578
|
+
/**
|
|
1579
|
+
* Select the slice state, using the slice's current reducerPath.
|
|
1580
|
+
*
|
|
1581
|
+
* Returns initial state if slice is not found.
|
|
1582
|
+
*/
|
|
1583
|
+
selectSlice(state: { [K in ReducerPath]?: State | undefined; }): State;
|
|
1613
1584
|
};
|
|
1614
1585
|
/**
|
|
1615
1586
|
* Options for `createSlice()`.
|
|
@@ -1617,81 +1588,81 @@ type InjectedSlice<State = any, CaseReducers extends SliceCaseReducers<State> =
|
|
|
1617
1588
|
* @public
|
|
1618
1589
|
*/
|
|
1619
1590
|
interface CreateSliceOptions<State = any, CR extends SliceCaseReducers<State> = SliceCaseReducers<State>, Name extends string = string, ReducerPath extends string = Name, Selectors extends SliceSelectors<State> = SliceSelectors<State>> {
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1591
|
+
/**
|
|
1592
|
+
* The slice's name. Used to namespace the generated action types.
|
|
1593
|
+
*/
|
|
1594
|
+
name: Name;
|
|
1595
|
+
/**
|
|
1596
|
+
* The slice's reducer path. Used when injecting into a combined slice reducer.
|
|
1597
|
+
*/
|
|
1598
|
+
reducerPath?: ReducerPath;
|
|
1599
|
+
/**
|
|
1600
|
+
* The initial state that should be used when the reducer is called the first time. This may also be a "lazy initializer" function, which should return an initial state value when called. This will be used whenever the reducer is called with `undefined` as its state value, and is primarily useful for cases like reading initial state from `localStorage`.
|
|
1601
|
+
*/
|
|
1602
|
+
initialState: State | (() => State);
|
|
1603
|
+
/**
|
|
1604
|
+
* A mapping from action types to action-type-specific *case reducer*
|
|
1605
|
+
* functions. For every action type, a matching action creator will be
|
|
1606
|
+
* generated using `createAction()`.
|
|
1607
|
+
*/
|
|
1608
|
+
reducers: ValidateSliceCaseReducers<State, CR> | ((creators: ReducerCreators<State>) => CR);
|
|
1609
|
+
/**
|
|
1610
|
+
* A callback that receives a *builder* object to define
|
|
1611
|
+
* case reducers via calls to `builder.addCase(actionCreatorOrType, reducer)`.
|
|
1612
|
+
*
|
|
1613
|
+
*
|
|
1614
|
+
* @example
|
|
1615
|
+
* ```ts
|
|
1616
|
+
* import type { Action } from '@reduxjs/toolkit';
|
|
1617
|
+
* import { createAction, createSlice } from '@reduxjs/toolkit';
|
|
1618
|
+
*
|
|
1619
|
+
* const incrementBy = createAction<number>('incrementBy');
|
|
1620
|
+
* const decrement = createAction('decrement');
|
|
1621
|
+
*
|
|
1622
|
+
* interface RejectedAction extends Action {
|
|
1623
|
+
* error: Error;
|
|
1624
|
+
* }
|
|
1625
|
+
*
|
|
1626
|
+
* function isRejectedAction(action: Action): action is RejectedAction {
|
|
1627
|
+
* return action.type.endsWith('rejected');
|
|
1628
|
+
* }
|
|
1629
|
+
*
|
|
1630
|
+
* createSlice({
|
|
1631
|
+
* name: 'counter',
|
|
1632
|
+
* initialState: 0,
|
|
1633
|
+
* reducers: {},
|
|
1634
|
+
* extraReducers: (builder) => {
|
|
1635
|
+
* builder
|
|
1636
|
+
* .addCase(incrementBy, (state, action) => {
|
|
1637
|
+
* // action is inferred correctly here if using TS
|
|
1638
|
+
* })
|
|
1639
|
+
* // You can chain calls, or have separate `builder.addCase()` lines each time
|
|
1640
|
+
* .addCase(decrement, (state, action) => {})
|
|
1641
|
+
* // You can match a range of action types
|
|
1642
|
+
* .addMatcher(
|
|
1643
|
+
* isRejectedAction,
|
|
1644
|
+
* // `action` will be inferred as a RejectedAction due to isRejectedAction being defined as a type guard
|
|
1645
|
+
* (state, action) => {},
|
|
1646
|
+
* )
|
|
1647
|
+
* // and provide a default case if no other handlers matched
|
|
1648
|
+
* .addDefaultCase((state, action) => {});
|
|
1649
|
+
* },
|
|
1650
|
+
* });
|
|
1651
|
+
* ```
|
|
1652
|
+
*/
|
|
1653
|
+
extraReducers?: (builder: ActionReducerMapBuilder<State>) => void;
|
|
1654
|
+
/**
|
|
1655
|
+
* A map of selectors that receive the slice's state and any additional arguments, and return a result.
|
|
1656
|
+
*/
|
|
1657
|
+
selectors?: Selectors;
|
|
1687
1658
|
}
|
|
1688
1659
|
declare enum ReducerType {
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1660
|
+
reducer = "reducer",
|
|
1661
|
+
reducerWithPrepare = "reducerWithPrepare",
|
|
1662
|
+
asyncThunk = "asyncThunk"
|
|
1692
1663
|
}
|
|
1693
1664
|
type ReducerDefinition<T extends ReducerType = ReducerType> = {
|
|
1694
|
-
|
|
1665
|
+
_reducerDefinitionType: T;
|
|
1695
1666
|
};
|
|
1696
1667
|
type CaseReducerDefinition<S = any, A extends Action = UnknownAction> = CaseReducer<S, A> & ReducerDefinition<ReducerType.reducer>;
|
|
1697
1668
|
/**
|
|
@@ -1700,35 +1671,33 @@ type CaseReducerDefinition<S = any, A extends Action = UnknownAction> = CaseRedu
|
|
|
1700
1671
|
* @public
|
|
1701
1672
|
*/
|
|
1702
1673
|
type CaseReducerWithPrepare<State, Action extends PayloadAction> = {
|
|
1703
|
-
|
|
1704
|
-
|
|
1674
|
+
reducer: CaseReducer<State, Action>;
|
|
1675
|
+
prepare: PrepareAction<Action['payload']>;
|
|
1705
1676
|
};
|
|
1706
1677
|
type AsyncThunkSliceReducerConfig<State, ThunkArg extends any, Returned = unknown, ThunkApiConfig extends AsyncThunkConfig = {}> = AsyncThunkReducers<State, ThunkArg, Returned, ThunkApiConfig> & {
|
|
1707
|
-
|
|
1678
|
+
options?: AsyncThunkOptions<ThunkArg, ThunkApiConfig>;
|
|
1708
1679
|
};
|
|
1709
1680
|
type AsyncThunkSliceReducerDefinition<State, ThunkArg extends any, Returned = unknown, ThunkApiConfig extends AsyncThunkConfig = {}> = AsyncThunkSliceReducerConfig<State, ThunkArg, Returned, ThunkApiConfig> & ReducerDefinition<ReducerType.asyncThunk> & {
|
|
1710
|
-
|
|
1681
|
+
payloadCreator: AsyncThunkPayloadCreator<Returned, ThunkArg, ThunkApiConfig>;
|
|
1711
1682
|
};
|
|
1712
1683
|
/**
|
|
1713
1684
|
* Providing these as part of the config would cause circular types, so we disallow passing them
|
|
1714
1685
|
*/
|
|
1715
|
-
type PreventCircular<ThunkApiConfig> = {
|
|
1716
|
-
[K in keyof ThunkApiConfig]: K extends 'state' | 'dispatch' ? never : ThunkApiConfig[K];
|
|
1717
|
-
};
|
|
1686
|
+
type PreventCircular<ThunkApiConfig> = { [K in keyof ThunkApiConfig]: K extends 'state' | 'dispatch' ? never : ThunkApiConfig[K]; };
|
|
1718
1687
|
interface AsyncThunkCreator<State, CurriedThunkApiConfig extends PreventCircular<AsyncThunkConfig> = PreventCircular<AsyncThunkConfig>> {
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1688
|
+
<Returned, ThunkArg = void>(payloadCreator: AsyncThunkPayloadCreator<Returned, ThunkArg, CurriedThunkApiConfig>, config?: AsyncThunkSliceReducerConfig<State, ThunkArg, Returned, CurriedThunkApiConfig>): AsyncThunkSliceReducerDefinition<State, ThunkArg, Returned, CurriedThunkApiConfig>;
|
|
1689
|
+
<Returned, ThunkArg, ThunkApiConfig extends PreventCircular<AsyncThunkConfig> = {}>(payloadCreator: AsyncThunkPayloadCreator<Returned, ThunkArg, ThunkApiConfig>, config?: AsyncThunkSliceReducerConfig<State, ThunkArg, Returned, ThunkApiConfig>): AsyncThunkSliceReducerDefinition<State, ThunkArg, Returned, ThunkApiConfig>;
|
|
1690
|
+
withTypes<ThunkApiConfig extends PreventCircular<AsyncThunkConfig>>(): AsyncThunkCreator<State, OverrideThunkApiConfigs<CurriedThunkApiConfig, ThunkApiConfig>>;
|
|
1722
1691
|
}
|
|
1723
1692
|
interface ReducerCreators<State> {
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1693
|
+
reducer(caseReducer: CaseReducer<State, PayloadAction>): CaseReducerDefinition<State, PayloadAction>;
|
|
1694
|
+
reducer<Payload>(caseReducer: CaseReducer<State, PayloadAction<Payload>>): CaseReducerDefinition<State, PayloadAction<Payload>>;
|
|
1695
|
+
asyncThunk: AsyncThunkCreator<State>;
|
|
1696
|
+
preparedReducer<Prepare extends PrepareAction<any>>(prepare: Prepare, reducer: CaseReducer<State, ReturnType<_ActionCreatorWithPreparedPayload<Prepare>>>): {
|
|
1697
|
+
_reducerDefinitionType: ReducerType.reducerWithPrepare;
|
|
1698
|
+
prepare: Prepare;
|
|
1699
|
+
reducer: CaseReducer<State, ReturnType<_ActionCreatorWithPreparedPayload<Prepare>>>;
|
|
1700
|
+
};
|
|
1732
1701
|
}
|
|
1733
1702
|
/**
|
|
1734
1703
|
* The type describing a slice's `reducers` option.
|
|
@@ -1740,7 +1709,7 @@ type SliceCaseReducers<State> = Record<string, ReducerDefinition> | Record<strin
|
|
|
1740
1709
|
* The type describing a slice's `selectors` option.
|
|
1741
1710
|
*/
|
|
1742
1711
|
type SliceSelectors<State> = {
|
|
1743
|
-
|
|
1712
|
+
[K: string]: (sliceState: State, ...args: any[]) => any;
|
|
1744
1713
|
};
|
|
1745
1714
|
type SliceActionType<SliceName extends string, ActionName extends keyof any> = ActionName extends string | number ? `${SliceName}/${ActionName}` : string;
|
|
1746
1715
|
/**
|
|
@@ -1748,28 +1717,26 @@ type SliceActionType<SliceName extends string, ActionName extends keyof any> = A
|
|
|
1748
1717
|
*
|
|
1749
1718
|
* @public
|
|
1750
1719
|
*/
|
|
1751
|
-
type CaseReducerActions<CaseReducers extends SliceCaseReducers<any>, SliceName extends string> = {
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
} ? ActionCreatorForCaseReducer<Definition['reducer'], SliceActionType<SliceName, Type>> : ActionCreatorForCaseReducer<Definition, SliceActionType<SliceName, Type>> : never;
|
|
1757
|
-
};
|
|
1720
|
+
type CaseReducerActions<CaseReducers extends SliceCaseReducers<any>, SliceName extends string> = { [Type in keyof CaseReducers]: CaseReducers[Type] extends (infer Definition) ? Definition extends {
|
|
1721
|
+
prepare: any;
|
|
1722
|
+
} ? ActionCreatorForCaseReducerWithPrepare<Definition, SliceActionType<SliceName, Type>> : Definition extends AsyncThunkSliceReducerDefinition<any, infer ThunkArg, infer Returned, infer ThunkApiConfig> ? AsyncThunk<Returned, ThunkArg, ThunkApiConfig> : Definition extends {
|
|
1723
|
+
reducer: any;
|
|
1724
|
+
} ? ActionCreatorForCaseReducer<Definition['reducer'], SliceActionType<SliceName, Type>> : ActionCreatorForCaseReducer<Definition, SliceActionType<SliceName, Type>> : never; };
|
|
1758
1725
|
/**
|
|
1759
1726
|
* Get a `PayloadActionCreator` type for a passed `CaseReducerWithPrepare`
|
|
1760
1727
|
*
|
|
1761
1728
|
* @internal
|
|
1762
1729
|
*/
|
|
1763
1730
|
type ActionCreatorForCaseReducerWithPrepare<CR extends {
|
|
1764
|
-
|
|
1731
|
+
prepare: any;
|
|
1765
1732
|
}, Type extends string> = _ActionCreatorWithPreparedPayload<CR['prepare'], Type>;
|
|
1766
1733
|
/**
|
|
1767
1734
|
* Get a `PayloadActionCreator` type for a passed `CaseReducer`
|
|
1768
1735
|
*
|
|
1769
1736
|
* @internal
|
|
1770
1737
|
*/
|
|
1771
|
-
type ActionCreatorForCaseReducer<CR, Type extends string> = CR extends (state: any, action: infer Action) => any ? Action extends {
|
|
1772
|
-
|
|
1738
|
+
type ActionCreatorForCaseReducer<CR, Type extends string> = CR extends ((state: any, action: infer Action) => any) ? Action extends {
|
|
1739
|
+
payload: infer P;
|
|
1773
1740
|
} ? PayloadActionCreator<P, Type> : ActionCreatorWithoutPayload<Type> : ActionCreatorWithoutPayload<Type>;
|
|
1774
1741
|
/**
|
|
1775
1742
|
* Extracts the CaseReducers out of a `reducers` object, even if they are
|
|
@@ -1777,22 +1744,18 @@ type ActionCreatorForCaseReducer<CR, Type extends string> = CR extends (state: a
|
|
|
1777
1744
|
*
|
|
1778
1745
|
* @internal
|
|
1779
1746
|
*/
|
|
1780
|
-
type SliceDefinedCaseReducers<CaseReducers extends SliceCaseReducers<any>> = {
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
type RemappedSelector<S extends Selector, NewState> = S extends Selector<any, infer R, infer P> ? Selector<NewState, R, P> & {
|
|
1786
|
-
unwrapped: S;
|
|
1747
|
+
type SliceDefinedCaseReducers<CaseReducers extends SliceCaseReducers<any>> = { [Type in keyof CaseReducers]: CaseReducers[Type] extends (infer Definition) ? Definition extends AsyncThunkSliceReducerDefinition<any, any, any> ? Id<Pick<Required<Definition>, 'fulfilled' | 'rejected' | 'pending' | 'settled'>> : Definition extends {
|
|
1748
|
+
reducer: infer Reducer;
|
|
1749
|
+
} ? Reducer : Definition : never; };
|
|
1750
|
+
type RemappedSelector<S extends Selector$1, NewState> = S extends Selector$1<any, infer R, infer P> ? Selector$1<NewState, R, P> & {
|
|
1751
|
+
unwrapped: S;
|
|
1787
1752
|
} : never;
|
|
1788
1753
|
/**
|
|
1789
1754
|
* Extracts the final selector type from the `selectors` object.
|
|
1790
1755
|
*
|
|
1791
1756
|
* Removes the `string` index signature from the default value.
|
|
1792
1757
|
*/
|
|
1793
|
-
type SliceDefinedSelectors<State, Selectors extends SliceSelectors<State>, RootState> = {
|
|
1794
|
-
[K in keyof Selectors as string extends K ? never : K]: RemappedSelector<Selectors[K], RootState>;
|
|
1795
|
-
};
|
|
1758
|
+
type SliceDefinedSelectors<State, Selectors extends SliceSelectors<State>, RootState> = { [K in keyof Selectors as string extends K ? never : K]: RemappedSelector<Selectors[K], RootState>; };
|
|
1796
1759
|
/**
|
|
1797
1760
|
* Used on a SliceCaseReducers object.
|
|
1798
1761
|
* Ensures that if a CaseReducer is a `CaseReducerWithPrepare`, that
|
|
@@ -1805,19 +1768,17 @@ type SliceDefinedSelectors<State, Selectors extends SliceSelectors<State>, RootS
|
|
|
1805
1768
|
*
|
|
1806
1769
|
* @public
|
|
1807
1770
|
*/
|
|
1808
|
-
type ValidateSliceCaseReducers<S, ACR extends SliceCaseReducers<S>> = ACR & {
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
} : {};
|
|
1814
|
-
};
|
|
1771
|
+
type ValidateSliceCaseReducers<S, ACR extends SliceCaseReducers<S>> = ACR & { [T in keyof ACR]: ACR[T] extends {
|
|
1772
|
+
reducer(s: S, action?: infer A): any;
|
|
1773
|
+
} ? {
|
|
1774
|
+
prepare(...a: never[]): Omit<A, 'type'>;
|
|
1775
|
+
} : {}; };
|
|
1815
1776
|
interface BuildCreateSliceConfig {
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1777
|
+
creators?: {
|
|
1778
|
+
asyncThunk?: typeof asyncThunkCreator;
|
|
1779
|
+
};
|
|
1819
1780
|
}
|
|
1820
|
-
declare function buildCreateSlice({ creators }?: BuildCreateSliceConfig): <State, CaseReducers extends SliceCaseReducers<State>, Name extends string, Selectors extends SliceSelectors<State>, ReducerPath extends string = Name>(options: CreateSliceOptions<State, CaseReducers, Name, ReducerPath, Selectors>) => Slice<State, CaseReducers, Name, ReducerPath, Selectors>;
|
|
1781
|
+
declare function buildCreateSlice({ creators }?: BuildCreateSliceConfig): <State, CaseReducers extends SliceCaseReducers<State>, Name extends string, Selectors extends SliceSelectors<State>, ReducerPath extends string = Name>(options: CreateSliceOptions<State, CaseReducers, Name, ReducerPath, Selectors>) => Slice$1<State, CaseReducers, Name, ReducerPath, Selectors>;
|
|
1821
1782
|
/**
|
|
1822
1783
|
* A function that accepts an initial state, an object full of reducer
|
|
1823
1784
|
* functions, and a "slice name", and automatically generates
|
|
@@ -1826,13 +1787,15 @@ declare function buildCreateSlice({ creators }?: BuildCreateSliceConfig): <State
|
|
|
1826
1787
|
*
|
|
1827
1788
|
* @public
|
|
1828
1789
|
*/
|
|
1829
|
-
declare const createSlice: <State, CaseReducers extends SliceCaseReducers<State>, Name extends string, Selectors extends SliceSelectors<State>, ReducerPath extends string = Name>(options: CreateSliceOptions<State, CaseReducers, Name, ReducerPath, Selectors>) => Slice<State, CaseReducers, Name, ReducerPath, Selectors>;
|
|
1830
|
-
|
|
1790
|
+
declare const createSlice: <State, CaseReducers extends SliceCaseReducers<State>, Name extends string, Selectors extends SliceSelectors<State>, ReducerPath extends string = Name>(options: CreateSliceOptions<State, CaseReducers, Name, ReducerPath, Selectors>) => Slice$1<State, CaseReducers, Name, ReducerPath, Selectors>;
|
|
1791
|
+
//#endregion
|
|
1792
|
+
//#region src/entities/state_selectors.d.ts
|
|
1831
1793
|
type AnyCreateSelectorFunction = CreateSelectorFunction<any, any, any>;
|
|
1832
1794
|
type GetSelectorsOptions = {
|
|
1833
|
-
|
|
1795
|
+
createSelector?: AnyCreateSelectorFunction;
|
|
1834
1796
|
};
|
|
1835
|
-
|
|
1797
|
+
//#endregion
|
|
1798
|
+
//#region src/entities/models.d.ts
|
|
1836
1799
|
/**
|
|
1837
1800
|
* @public
|
|
1838
1801
|
*/
|
|
@@ -1849,83 +1812,85 @@ type IdSelector<T, Id extends EntityId> = (model: T) => Id;
|
|
|
1849
1812
|
* @public
|
|
1850
1813
|
*/
|
|
1851
1814
|
type Update<T, Id extends EntityId> = {
|
|
1852
|
-
|
|
1853
|
-
|
|
1815
|
+
id: Id;
|
|
1816
|
+
changes: Partial<T>;
|
|
1854
1817
|
};
|
|
1855
1818
|
/**
|
|
1856
1819
|
* @public
|
|
1857
1820
|
*/
|
|
1858
1821
|
interface EntityState<T, Id extends EntityId> {
|
|
1859
|
-
|
|
1860
|
-
|
|
1822
|
+
ids: Id[];
|
|
1823
|
+
entities: Record<Id, T>;
|
|
1861
1824
|
}
|
|
1862
1825
|
/**
|
|
1863
1826
|
* @public
|
|
1864
1827
|
*/
|
|
1865
1828
|
interface EntityAdapterOptions<T, Id extends EntityId> {
|
|
1866
|
-
|
|
1867
|
-
|
|
1829
|
+
selectId?: IdSelector<T, Id>;
|
|
1830
|
+
sortComparer?: false | Comparer<T>;
|
|
1868
1831
|
}
|
|
1869
1832
|
type PreventAny<S, T, Id extends EntityId> = CastAny<S, EntityState<T, Id>>;
|
|
1870
|
-
type DraftableEntityState<T, Id extends EntityId> = EntityState<T, Id> | Draft<EntityState<T, Id>>;
|
|
1833
|
+
type DraftableEntityState<T, Id extends EntityId> = EntityState<T, Id> | Draft$1<EntityState<T, Id>>;
|
|
1871
1834
|
/**
|
|
1872
1835
|
* @public
|
|
1873
1836
|
*/
|
|
1874
1837
|
interface EntityStateAdapter<T, Id extends EntityId> {
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1838
|
+
addOne<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, entity: T): S;
|
|
1839
|
+
addOne<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, action: PayloadAction<T>): S;
|
|
1840
|
+
addMany<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, entities: readonly T[] | Record<Id, T>): S;
|
|
1841
|
+
addMany<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, entities: PayloadAction<readonly T[] | Record<Id, T>>): S;
|
|
1842
|
+
setOne<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, entity: T): S;
|
|
1843
|
+
setOne<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, action: PayloadAction<T>): S;
|
|
1844
|
+
setMany<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, entities: readonly T[] | Record<Id, T>): S;
|
|
1845
|
+
setMany<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, entities: PayloadAction<readonly T[] | Record<Id, T>>): S;
|
|
1846
|
+
setAll<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, entities: readonly T[] | Record<Id, T>): S;
|
|
1847
|
+
setAll<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, entities: PayloadAction<readonly T[] | Record<Id, T>>): S;
|
|
1848
|
+
removeOne<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, key: Id): S;
|
|
1849
|
+
removeOne<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, key: PayloadAction<Id>): S;
|
|
1850
|
+
removeMany<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, keys: readonly Id[]): S;
|
|
1851
|
+
removeMany<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, keys: PayloadAction<readonly Id[]>): S;
|
|
1852
|
+
removeAll<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>): S;
|
|
1853
|
+
updateOne<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, update: Update<T, Id>): S;
|
|
1854
|
+
updateOne<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, update: PayloadAction<Update<T, Id>>): S;
|
|
1855
|
+
updateMany<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, updates: ReadonlyArray<Update<T, Id>>): S;
|
|
1856
|
+
updateMany<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, updates: PayloadAction<ReadonlyArray<Update<T, Id>>>): S;
|
|
1857
|
+
upsertOne<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, entity: T): S;
|
|
1858
|
+
upsertOne<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, entity: PayloadAction<T>): S;
|
|
1859
|
+
upsertMany<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, entities: readonly T[] | Record<Id, T>): S;
|
|
1860
|
+
upsertMany<S extends DraftableEntityState<T, Id>>(state: PreventAny<S, T, Id>, entities: PayloadAction<readonly T[] | Record<Id, T>>): S;
|
|
1898
1861
|
}
|
|
1899
1862
|
/**
|
|
1900
1863
|
* @public
|
|
1901
1864
|
*/
|
|
1902
1865
|
interface EntitySelectors<T, V, IdType extends EntityId> {
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1866
|
+
selectIds: (state: V) => IdType[];
|
|
1867
|
+
selectEntities: (state: V) => Record<IdType, T>;
|
|
1868
|
+
selectAll: (state: V) => T[];
|
|
1869
|
+
selectTotal: (state: V) => number;
|
|
1870
|
+
selectById: (state: V, id: IdType) => Id<UncheckedIndexedAccess<T>>;
|
|
1908
1871
|
}
|
|
1909
1872
|
/**
|
|
1910
1873
|
* @public
|
|
1911
1874
|
*/
|
|
1912
1875
|
interface EntityStateFactory<T, Id extends EntityId> {
|
|
1913
|
-
|
|
1914
|
-
|
|
1876
|
+
getInitialState(state?: undefined, entities?: Record<Id, T> | readonly T[]): EntityState<T, Id>;
|
|
1877
|
+
getInitialState<S extends object>(state: S, entities?: Record<Id, T> | readonly T[]): EntityState<T, Id> & S;
|
|
1915
1878
|
}
|
|
1916
1879
|
/**
|
|
1917
1880
|
* @public
|
|
1918
1881
|
*/
|
|
1919
1882
|
interface EntityAdapter<T, Id extends EntityId> extends EntityStateAdapter<T, Id>, EntityStateFactory<T, Id>, Required<EntityAdapterOptions<T, Id>> {
|
|
1920
|
-
|
|
1921
|
-
|
|
1883
|
+
getSelectors(selectState?: undefined, options?: GetSelectorsOptions): EntitySelectors<T, EntityState<T, Id>, Id>;
|
|
1884
|
+
getSelectors<V>(selectState: (state: V) => EntityState<T, Id>, options?: GetSelectorsOptions): EntitySelectors<T, V, Id>;
|
|
1922
1885
|
}
|
|
1923
|
-
|
|
1886
|
+
//#endregion
|
|
1887
|
+
//#region src/entities/create_adapter.d.ts
|
|
1924
1888
|
declare function createEntityAdapter<T, Id extends EntityId>(options: WithRequiredProp<EntityAdapterOptions<T, Id>, 'selectId'>): EntityAdapter<T, Id>;
|
|
1925
1889
|
declare function createEntityAdapter<T extends {
|
|
1926
|
-
|
|
1890
|
+
id: EntityId;
|
|
1927
1891
|
}>(options?: Omit<EntityAdapterOptions<T, T['id']>, 'selectId'>): EntityAdapter<T, T['id']>;
|
|
1928
|
-
|
|
1892
|
+
//#endregion
|
|
1893
|
+
//#region src/matchers.d.ts
|
|
1929
1894
|
/** @public */
|
|
1930
1895
|
type ActionMatchingAnyOf<Matchers extends Matcher<any>[]> = ActionFromMatcher<Matchers[number]>;
|
|
1931
1896
|
/** @public */
|
|
@@ -2001,9 +1966,9 @@ declare function isRejected<AsyncThunks extends [AnyAsyncThunk, ...AnyAsyncThunk
|
|
|
2001
1966
|
*/
|
|
2002
1967
|
declare function isRejected(action: any): action is UnknownAsyncThunkRejectedAction;
|
|
2003
1968
|
type RejectedWithValueActionFromAsyncThunk<T extends AnyAsyncThunk> = ActionFromMatcher<T['rejected']> & (T extends AsyncThunk<any, any, {
|
|
2004
|
-
|
|
1969
|
+
rejectValue: infer RejectedValue;
|
|
2005
1970
|
}> ? {
|
|
2006
|
-
|
|
1971
|
+
payload: RejectedValue;
|
|
2007
1972
|
} : unknown);
|
|
2008
1973
|
/**
|
|
2009
1974
|
* A higher-order function that returns a function that may be used to check
|
|
@@ -2055,15 +2020,15 @@ declare function isFulfilled<AsyncThunks extends [AnyAsyncThunk, ...AnyAsyncThun
|
|
|
2055
2020
|
declare function isFulfilled(action: any): action is UnknownAsyncThunkFulfilledAction;
|
|
2056
2021
|
type UnknownAsyncThunkAction = UnknownAsyncThunkPendingAction | UnknownAsyncThunkRejectedAction | UnknownAsyncThunkFulfilledAction;
|
|
2057
2022
|
type AnyAsyncThunk = {
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2023
|
+
pending: {
|
|
2024
|
+
match: (action: any) => action is any;
|
|
2025
|
+
};
|
|
2026
|
+
fulfilled: {
|
|
2027
|
+
match: (action: any) => action is any;
|
|
2028
|
+
};
|
|
2029
|
+
rejected: {
|
|
2030
|
+
match: (action: any) => action is any;
|
|
2031
|
+
};
|
|
2067
2032
|
};
|
|
2068
2033
|
type ActionsFromAsyncThunk<T extends AnyAsyncThunk> = ActionFromMatcher<T['pending']> | ActionFromMatcher<T['fulfilled']> | ActionFromMatcher<T['rejected']>;
|
|
2069
2034
|
/**
|
|
@@ -2087,26 +2052,29 @@ declare function isAsyncThunkAction<AsyncThunks extends [AnyAsyncThunk, ...AnyAs
|
|
|
2087
2052
|
* @public
|
|
2088
2053
|
*/
|
|
2089
2054
|
declare function isAsyncThunkAction(action: any): action is UnknownAsyncThunkAction;
|
|
2090
|
-
|
|
2055
|
+
//#endregion
|
|
2056
|
+
//#region src/nanoid.d.ts
|
|
2091
2057
|
/**
|
|
2092
2058
|
*
|
|
2093
2059
|
* @public
|
|
2094
2060
|
*/
|
|
2095
2061
|
declare let nanoid: (size?: number) => string;
|
|
2096
|
-
|
|
2062
|
+
//#endregion
|
|
2063
|
+
//#region src/listenerMiddleware/exceptions.d.ts
|
|
2097
2064
|
declare class TaskAbortError implements SerializedError {
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2065
|
+
code: string | undefined;
|
|
2066
|
+
name: string;
|
|
2067
|
+
message: string;
|
|
2068
|
+
constructor(code: string | undefined);
|
|
2102
2069
|
}
|
|
2103
|
-
|
|
2070
|
+
//#endregion
|
|
2071
|
+
//#region src/listenerMiddleware/types.d.ts
|
|
2104
2072
|
/**
|
|
2105
2073
|
* Types copied from RTK
|
|
2106
2074
|
*/
|
|
2107
2075
|
/** @internal */
|
|
2108
2076
|
type TypedActionCreatorWithMatchFunction<Type extends string> = TypedActionCreator<Type> & {
|
|
2109
|
-
|
|
2077
|
+
match: MatchFunction<any>;
|
|
2110
2078
|
};
|
|
2111
2079
|
/** @internal */
|
|
2112
2080
|
type AnyListenerPredicate<State> = (action: UnknownAction, currentState: State, originalState: State) => boolean;
|
|
@@ -2114,212 +2082,211 @@ type AnyListenerPredicate<State> = (action: UnknownAction, currentState: State,
|
|
|
2114
2082
|
type ListenerPredicate<ActionType extends Action, State> = (action: UnknownAction, currentState: State, originalState: State) => action is ActionType;
|
|
2115
2083
|
/** @public */
|
|
2116
2084
|
interface ConditionFunction<State> {
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
(predicate: () => boolean, timeout?: number): Promise<boolean>;
|
|
2085
|
+
(predicate: AnyListenerPredicate<State>, timeout?: number): Promise<boolean>;
|
|
2086
|
+
(predicate: () => boolean, timeout?: number): Promise<boolean>;
|
|
2120
2087
|
}
|
|
2121
2088
|
/** @internal */
|
|
2122
2089
|
type MatchFunction<T> = (v: any) => v is T;
|
|
2123
2090
|
/** @public */
|
|
2124
2091
|
interface ForkedTaskAPI {
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2092
|
+
/**
|
|
2093
|
+
* Returns a promise that resolves when `waitFor` resolves or
|
|
2094
|
+
* rejects if the task or the parent listener has been cancelled or is completed.
|
|
2095
|
+
*/
|
|
2096
|
+
pause<W>(waitFor: Promise<W>): Promise<W>;
|
|
2097
|
+
/**
|
|
2098
|
+
* Returns a promise that resolves after `timeoutMs` or
|
|
2099
|
+
* rejects if the task or the parent listener has been cancelled or is completed.
|
|
2100
|
+
* @param timeoutMs
|
|
2101
|
+
*/
|
|
2102
|
+
delay(timeoutMs: number): Promise<void>;
|
|
2103
|
+
/**
|
|
2104
|
+
* An abort signal whose `aborted` property is set to `true`
|
|
2105
|
+
* if the task execution is either aborted or completed.
|
|
2106
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
|
|
2107
|
+
*/
|
|
2108
|
+
signal: AbortSignal;
|
|
2142
2109
|
}
|
|
2143
2110
|
/** @public */
|
|
2144
2111
|
interface AsyncTaskExecutor<T> {
|
|
2145
|
-
|
|
2112
|
+
(forkApi: ForkedTaskAPI): Promise<T>;
|
|
2146
2113
|
}
|
|
2147
2114
|
/** @public */
|
|
2148
2115
|
interface SyncTaskExecutor<T> {
|
|
2149
|
-
|
|
2116
|
+
(forkApi: ForkedTaskAPI): T;
|
|
2150
2117
|
}
|
|
2151
2118
|
/** @public */
|
|
2152
2119
|
type ForkedTaskExecutor<T> = AsyncTaskExecutor<T> | SyncTaskExecutor<T>;
|
|
2153
2120
|
/** @public */
|
|
2154
2121
|
type TaskResolved<T> = {
|
|
2155
|
-
|
|
2156
|
-
|
|
2122
|
+
readonly status: 'ok';
|
|
2123
|
+
readonly value: T;
|
|
2157
2124
|
};
|
|
2158
2125
|
/** @public */
|
|
2159
2126
|
type TaskRejected = {
|
|
2160
|
-
|
|
2161
|
-
|
|
2127
|
+
readonly status: 'rejected';
|
|
2128
|
+
readonly error: unknown;
|
|
2162
2129
|
};
|
|
2163
2130
|
/** @public */
|
|
2164
2131
|
type TaskCancelled = {
|
|
2165
|
-
|
|
2166
|
-
|
|
2132
|
+
readonly status: 'cancelled';
|
|
2133
|
+
readonly error: TaskAbortError;
|
|
2167
2134
|
};
|
|
2168
2135
|
/** @public */
|
|
2169
2136
|
type TaskResult<Value> = TaskResolved<Value> | TaskRejected | TaskCancelled;
|
|
2170
2137
|
/** @public */
|
|
2171
2138
|
interface ForkedTask<T> {
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2139
|
+
/**
|
|
2140
|
+
* A promise that resolves when the task is either completed or cancelled or rejects
|
|
2141
|
+
* if parent listener execution is cancelled or completed.
|
|
2142
|
+
*
|
|
2143
|
+
* ### Example
|
|
2144
|
+
* ```ts
|
|
2145
|
+
* const result = await fork(async (forkApi) => Promise.resolve(4)).result;
|
|
2146
|
+
*
|
|
2147
|
+
* if (result.status === 'ok') {
|
|
2148
|
+
* console.log(result.value); // logs 4
|
|
2149
|
+
* }
|
|
2150
|
+
* ```
|
|
2151
|
+
*/
|
|
2152
|
+
result: Promise<TaskResult<T>>;
|
|
2153
|
+
/**
|
|
2154
|
+
* Cancel task if it is in progress or not yet started,
|
|
2155
|
+
* it is noop otherwise.
|
|
2156
|
+
*/
|
|
2157
|
+
cancel(): void;
|
|
2191
2158
|
}
|
|
2192
2159
|
/** @public */
|
|
2193
2160
|
interface ForkOptions {
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2161
|
+
/**
|
|
2162
|
+
* If true, causes the parent task to not be marked as complete until
|
|
2163
|
+
* all autoJoined forks have completed or failed.
|
|
2164
|
+
*/
|
|
2165
|
+
autoJoin: boolean;
|
|
2199
2166
|
}
|
|
2200
2167
|
/** @public */
|
|
2201
2168
|
interface ListenerEffectAPI<State, DispatchType extends Dispatch, ExtraArgument = unknown> extends MiddlewareAPI<DispatchType, State> {
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2169
|
+
/**
|
|
2170
|
+
* Returns the store state as it existed when the action was originally dispatched, _before_ the reducers ran.
|
|
2171
|
+
*
|
|
2172
|
+
* ### Synchronous invocation
|
|
2173
|
+
*
|
|
2174
|
+
* This function can **only** be invoked **synchronously**, it throws error otherwise.
|
|
2175
|
+
*
|
|
2176
|
+
* @example
|
|
2177
|
+
*
|
|
2178
|
+
* ```ts
|
|
2179
|
+
* middleware.startListening({
|
|
2180
|
+
* predicate: () => true,
|
|
2181
|
+
* async effect(_, { getOriginalState }) {
|
|
2182
|
+
* getOriginalState(); // sync: OK!
|
|
2183
|
+
*
|
|
2184
|
+
* setTimeout(getOriginalState, 0); // async: throws Error
|
|
2185
|
+
*
|
|
2186
|
+
* await Promise.resolve();
|
|
2187
|
+
*
|
|
2188
|
+
* getOriginalState(); // async: throws Error
|
|
2189
|
+
* },
|
|
2190
|
+
* });
|
|
2191
|
+
* ```
|
|
2192
|
+
*/
|
|
2193
|
+
getOriginalState: () => State;
|
|
2194
|
+
/**
|
|
2195
|
+
* Removes the listener entry from the middleware and prevent future instances of the listener from running.
|
|
2196
|
+
*
|
|
2197
|
+
* It does **not** cancel any active instances.
|
|
2198
|
+
*/
|
|
2199
|
+
unsubscribe(): void;
|
|
2200
|
+
/**
|
|
2201
|
+
* It will subscribe a listener if it was previously removed, noop otherwise.
|
|
2202
|
+
*/
|
|
2203
|
+
subscribe(): void;
|
|
2204
|
+
/**
|
|
2205
|
+
* Returns a promise that resolves when the input predicate returns `true` or
|
|
2206
|
+
* rejects if the listener has been cancelled or is completed.
|
|
2207
|
+
*
|
|
2208
|
+
* The return value is `true` if the predicate succeeds or `false` if a timeout is provided and expires first.
|
|
2209
|
+
*
|
|
2210
|
+
* ### Example
|
|
2211
|
+
*
|
|
2212
|
+
* ```ts
|
|
2213
|
+
* import { createAction } from '@reduxjs/toolkit';
|
|
2214
|
+
*
|
|
2215
|
+
* const updateBy = createAction<number>('counter/updateBy');
|
|
2216
|
+
*
|
|
2217
|
+
* middleware.startListening({
|
|
2218
|
+
* actionCreator: updateBy,
|
|
2219
|
+
* async effect(_, { condition }) {
|
|
2220
|
+
* // wait at most 3s for `updateBy` actions.
|
|
2221
|
+
* if (await condition(updateBy.match, 3_000)) {
|
|
2222
|
+
* // `updateBy` has been dispatched twice in less than 3s.
|
|
2223
|
+
* }
|
|
2224
|
+
* },
|
|
2225
|
+
* });
|
|
2226
|
+
* ```
|
|
2227
|
+
*/
|
|
2228
|
+
condition: ConditionFunction<State>;
|
|
2229
|
+
/**
|
|
2230
|
+
* Returns a promise that resolves when the input predicate returns `true` or
|
|
2231
|
+
* rejects if the listener has been cancelled or is completed.
|
|
2232
|
+
*
|
|
2233
|
+
* The return value is the `[action, currentState, previousState]` combination that the predicate saw as arguments.
|
|
2234
|
+
*
|
|
2235
|
+
* The promise resolves to null if a timeout is provided and expires first,
|
|
2236
|
+
*
|
|
2237
|
+
* ### Example
|
|
2238
|
+
*
|
|
2239
|
+
* ```ts
|
|
2240
|
+
* const updateBy = createAction<number>('counter/updateBy');
|
|
2241
|
+
*
|
|
2242
|
+
* middleware.startListening({
|
|
2243
|
+
* actionCreator: updateBy,
|
|
2244
|
+
* async effect(_, { take }) {
|
|
2245
|
+
* const [{ payload }] = await take(updateBy.match);
|
|
2246
|
+
* console.log(payload); // logs 5;
|
|
2247
|
+
* }
|
|
2248
|
+
* })
|
|
2249
|
+
*
|
|
2250
|
+
* store.dispatch(updateBy(5));
|
|
2251
|
+
* ```
|
|
2252
|
+
*/
|
|
2253
|
+
take: TakePattern<State>;
|
|
2254
|
+
/**
|
|
2255
|
+
* Cancels all other running instances of this same listener except for the one that made this call.
|
|
2256
|
+
*/
|
|
2257
|
+
cancelActiveListeners: () => void;
|
|
2258
|
+
/**
|
|
2259
|
+
* Cancels the instance of this listener that made this call.
|
|
2260
|
+
*/
|
|
2261
|
+
cancel: () => void;
|
|
2262
|
+
/**
|
|
2263
|
+
* Throws a `TaskAbortError` if this listener has been cancelled
|
|
2264
|
+
*/
|
|
2265
|
+
throwIfCancelled: () => void;
|
|
2266
|
+
/**
|
|
2267
|
+
* An abort signal whose `aborted` property is set to `true`
|
|
2268
|
+
* if the listener execution is either aborted or completed.
|
|
2269
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
|
|
2270
|
+
*/
|
|
2271
|
+
signal: AbortSignal;
|
|
2272
|
+
/**
|
|
2273
|
+
* Returns a promise that resolves after `timeoutMs` or
|
|
2274
|
+
* rejects if the listener has been cancelled or is completed.
|
|
2275
|
+
*/
|
|
2276
|
+
delay(timeoutMs: number): Promise<void>;
|
|
2277
|
+
/**
|
|
2278
|
+
* Queues in the next microtask the execution of a task.
|
|
2279
|
+
* @param executor
|
|
2280
|
+
* @param options
|
|
2281
|
+
*/
|
|
2282
|
+
fork<T>(executor: ForkedTaskExecutor<T>, options?: ForkOptions): ForkedTask<T>;
|
|
2283
|
+
/**
|
|
2284
|
+
* Returns a promise that resolves when `waitFor` resolves or
|
|
2285
|
+
* rejects if the listener has been cancelled or is completed.
|
|
2286
|
+
* @param promise
|
|
2287
|
+
*/
|
|
2288
|
+
pause<M>(promise: Promise<M>): Promise<M>;
|
|
2289
|
+
extra: ExtraArgument;
|
|
2323
2290
|
}
|
|
2324
2291
|
/** @public */
|
|
2325
2292
|
type ListenerEffect<ActionType extends Action, State, DispatchType extends Dispatch, ExtraArgument = unknown> = (action: ActionType, api: ListenerEffectAPI<State, DispatchType, ExtraArgument>) => void | Promise<void>;
|
|
@@ -2328,10 +2295,10 @@ type ListenerEffect<ActionType extends Action, State, DispatchType extends Dispa
|
|
|
2328
2295
|
* @public
|
|
2329
2296
|
*/
|
|
2330
2297
|
interface ListenerErrorInfo {
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2298
|
+
/**
|
|
2299
|
+
* Which function has generated the exception.
|
|
2300
|
+
*/
|
|
2301
|
+
raisedBy: 'effect' | 'predicate';
|
|
2335
2302
|
}
|
|
2336
2303
|
/**
|
|
2337
2304
|
* Gets notified with synchronous and asynchronous errors raised by `listeners` or `predicates`.
|
|
@@ -2340,29 +2307,29 @@ interface ListenerErrorInfo {
|
|
|
2340
2307
|
* @public
|
|
2341
2308
|
*/
|
|
2342
2309
|
interface ListenerErrorHandler {
|
|
2343
|
-
|
|
2310
|
+
(error: unknown, errorInfo: ListenerErrorInfo): void;
|
|
2344
2311
|
}
|
|
2345
2312
|
/** @public */
|
|
2346
2313
|
interface CreateListenerMiddlewareOptions<ExtraArgument = unknown> {
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2314
|
+
extra?: ExtraArgument;
|
|
2315
|
+
/**
|
|
2316
|
+
* Receives synchronous errors that are raised by `listener` and `listenerOption.predicate`.
|
|
2317
|
+
*/
|
|
2318
|
+
onError?: ListenerErrorHandler;
|
|
2352
2319
|
}
|
|
2353
2320
|
/** @public */
|
|
2354
|
-
type ListenerMiddleware<State = unknown, DispatchType extends ThunkDispatch<State, unknown, Action> = ThunkDispatch<State, unknown, UnknownAction>, ExtraArgument = unknown> = Middleware<{
|
|
2355
|
-
|
|
2321
|
+
type ListenerMiddleware<State = unknown, DispatchType extends ThunkDispatch$1<State, unknown, Action> = ThunkDispatch$1<State, unknown, UnknownAction>, ExtraArgument = unknown> = Middleware<{
|
|
2322
|
+
(action: Action<'listenerMiddleware/add'>): UnsubscribeListener;
|
|
2356
2323
|
}, State, DispatchType>;
|
|
2357
2324
|
/** @public */
|
|
2358
|
-
interface ListenerMiddlewareInstance<StateType = unknown, DispatchType extends ThunkDispatch<StateType, unknown, Action> = ThunkDispatch<StateType, unknown, UnknownAction>, ExtraArgument = unknown> {
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2325
|
+
interface ListenerMiddlewareInstance<StateType = unknown, DispatchType extends ThunkDispatch$1<StateType, unknown, Action> = ThunkDispatch$1<StateType, unknown, UnknownAction>, ExtraArgument = unknown> {
|
|
2326
|
+
middleware: ListenerMiddleware<StateType, DispatchType, ExtraArgument>;
|
|
2327
|
+
startListening: AddListenerOverloads<UnsubscribeListener, StateType, DispatchType, ExtraArgument> & TypedStartListening<StateType, DispatchType, ExtraArgument>;
|
|
2328
|
+
stopListening: RemoveListenerOverloads<StateType, DispatchType> & TypedStopListening<StateType, DispatchType>;
|
|
2329
|
+
/**
|
|
2330
|
+
* Unsubscribes all listeners, cancels running listeners and tasks.
|
|
2331
|
+
*/
|
|
2332
|
+
clearListeners: () => void;
|
|
2366
2333
|
}
|
|
2367
2334
|
/**
|
|
2368
2335
|
* API Function Overloads
|
|
@@ -2373,13 +2340,13 @@ type TakePatternOutputWithoutTimeout<State, Predicate extends AnyListenerPredica
|
|
|
2373
2340
|
type TakePatternOutputWithTimeout<State, Predicate extends AnyListenerPredicate<State>> = Predicate extends MatchFunction<infer ActionType> ? Promise<[ActionType, State, State] | null> : Promise<[UnknownAction, State, State] | null>;
|
|
2374
2341
|
/** @public */
|
|
2375
2342
|
interface TakePattern<State> {
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2343
|
+
<Predicate extends AnyListenerPredicate<State>>(predicate: Predicate): TakePatternOutputWithoutTimeout<State, Predicate>;
|
|
2344
|
+
<Predicate extends AnyListenerPredicate<State>>(predicate: Predicate, timeout: number): TakePatternOutputWithTimeout<State, Predicate>;
|
|
2345
|
+
<Predicate extends AnyListenerPredicate<State>>(predicate: Predicate, timeout?: number | undefined): TakePatternOutputWithTimeout<State, Predicate>;
|
|
2379
2346
|
}
|
|
2380
2347
|
/** @public */
|
|
2381
2348
|
interface UnsubscribeListenerOptions {
|
|
2382
|
-
|
|
2349
|
+
cancelActive?: true;
|
|
2383
2350
|
}
|
|
2384
2351
|
/** @public */
|
|
2385
2352
|
type UnsubscribeListener = (unsubscribeOptions?: UnsubscribeListenerOptions) => void;
|
|
@@ -2390,195 +2357,195 @@ type UnsubscribeListener = (unsubscribeOptions?: UnsubscribeListenerOptions) =>
|
|
|
2390
2357
|
*
|
|
2391
2358
|
* @public
|
|
2392
2359
|
*/
|
|
2393
|
-
type AddListenerOverloads<Return, StateType = unknown, DispatchType extends Dispatch = ThunkDispatch<StateType, unknown, UnknownAction>, ExtraArgument = unknown, AdditionalOptions = unknown> = {
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2360
|
+
type AddListenerOverloads<Return, StateType = unknown, DispatchType extends Dispatch = ThunkDispatch$1<StateType, unknown, UnknownAction>, ExtraArgument = unknown, AdditionalOptions = unknown> = {
|
|
2361
|
+
/** Accepts a "listener predicate" that is also a TS type predicate for the action*/
|
|
2362
|
+
<MiddlewareActionType extends UnknownAction, ListenerPredicateType extends ListenerPredicate<MiddlewareActionType, StateType>>(options: {
|
|
2363
|
+
actionCreator?: never;
|
|
2364
|
+
type?: never;
|
|
2365
|
+
matcher?: never;
|
|
2366
|
+
predicate: ListenerPredicateType;
|
|
2367
|
+
effect: ListenerEffect<ListenerPredicateGuardedActionType<ListenerPredicateType>, StateType, DispatchType, ExtraArgument>;
|
|
2368
|
+
} & AdditionalOptions): Return;
|
|
2369
|
+
/** Accepts an RTK action creator, like `incrementByAmount` */
|
|
2370
|
+
<ActionCreatorType extends TypedActionCreatorWithMatchFunction<any>>(options: {
|
|
2371
|
+
actionCreator: ActionCreatorType;
|
|
2372
|
+
type?: never;
|
|
2373
|
+
matcher?: never;
|
|
2374
|
+
predicate?: never;
|
|
2375
|
+
effect: ListenerEffect<ReturnType<ActionCreatorType>, StateType, DispatchType, ExtraArgument>;
|
|
2376
|
+
} & AdditionalOptions): Return;
|
|
2377
|
+
/** Accepts a specific action type string */
|
|
2378
|
+
<T extends string>(options: {
|
|
2379
|
+
actionCreator?: never;
|
|
2380
|
+
type: T;
|
|
2381
|
+
matcher?: never;
|
|
2382
|
+
predicate?: never;
|
|
2383
|
+
effect: ListenerEffect<Action<T>, StateType, DispatchType, ExtraArgument>;
|
|
2384
|
+
} & AdditionalOptions): Return;
|
|
2385
|
+
/** Accepts an RTK matcher function, such as `incrementByAmount.match` */
|
|
2386
|
+
<MatchFunctionType extends MatchFunction<Action>>(options: {
|
|
2387
|
+
actionCreator?: never;
|
|
2388
|
+
type?: never;
|
|
2389
|
+
matcher: MatchFunctionType;
|
|
2390
|
+
predicate?: never;
|
|
2391
|
+
effect: ListenerEffect<GuardedType<MatchFunctionType>, StateType, DispatchType, ExtraArgument>;
|
|
2392
|
+
} & AdditionalOptions): Return;
|
|
2393
|
+
/** Accepts a "listener predicate" that just returns a boolean, no type assertion */
|
|
2394
|
+
<ListenerPredicateType extends AnyListenerPredicate<StateType>>(options: {
|
|
2395
|
+
actionCreator?: never;
|
|
2396
|
+
type?: never;
|
|
2397
|
+
matcher?: never;
|
|
2398
|
+
predicate: ListenerPredicateType;
|
|
2399
|
+
effect: ListenerEffect<UnknownAction, StateType, DispatchType, ExtraArgument>;
|
|
2400
|
+
} & AdditionalOptions): Return;
|
|
2434
2401
|
};
|
|
2435
2402
|
/** @public */
|
|
2436
|
-
type RemoveListenerOverloads<StateType = unknown, DispatchType extends Dispatch = ThunkDispatch<StateType, unknown, UnknownAction>, ExtraArgument = unknown> = AddListenerOverloads<boolean, StateType, DispatchType, ExtraArgument, UnsubscribeListenerOptions>;
|
|
2403
|
+
type RemoveListenerOverloads<StateType = unknown, DispatchType extends Dispatch = ThunkDispatch$1<StateType, unknown, UnknownAction>, ExtraArgument = unknown> = AddListenerOverloads<boolean, StateType, DispatchType, ExtraArgument, UnsubscribeListenerOptions>;
|
|
2437
2404
|
/**
|
|
2438
2405
|
* A "pre-typed" version of `addListenerAction`, so the listener args are well-typed
|
|
2439
2406
|
*
|
|
2440
2407
|
* @public
|
|
2441
2408
|
*/
|
|
2442
|
-
type TypedAddListener<StateType, DispatchType extends Dispatch = ThunkDispatch<StateType, unknown, UnknownAction>, ExtraArgument = unknown, Payload = ListenerEntry<StateType, DispatchType>, T extends string = 'listenerMiddleware/add'> = BaseActionCreator<Payload, T> & AddListenerOverloads<PayloadAction<Payload, T>, StateType, DispatchType, ExtraArgument> & {
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2409
|
+
type TypedAddListener<StateType, DispatchType extends Dispatch = ThunkDispatch$1<StateType, unknown, UnknownAction>, ExtraArgument = unknown, Payload = ListenerEntry<StateType, DispatchType>, T extends string = 'listenerMiddleware/add'> = BaseActionCreator<Payload, T> & AddListenerOverloads<PayloadAction<Payload, T>, StateType, DispatchType, ExtraArgument> & {
|
|
2410
|
+
/**
|
|
2411
|
+
* Creates a "pre-typed" version of `addListener`
|
|
2412
|
+
* where the `state`, `dispatch` and `extra` types are predefined.
|
|
2413
|
+
*
|
|
2414
|
+
* This allows you to set the `state`, `dispatch` and `extra` types once,
|
|
2415
|
+
* eliminating the need to specify them with every `addListener` call.
|
|
2416
|
+
*
|
|
2417
|
+
* @returns A pre-typed `addListener` with the state, dispatch and extra types already defined.
|
|
2418
|
+
*
|
|
2419
|
+
* @example
|
|
2420
|
+
* ```ts
|
|
2421
|
+
* import { addListener } from '@reduxjs/toolkit';
|
|
2422
|
+
*
|
|
2423
|
+
* export const addAppListener = addListener.withTypes<
|
|
2424
|
+
* RootState,
|
|
2425
|
+
* AppDispatch,
|
|
2426
|
+
* ExtraArguments
|
|
2427
|
+
* >();
|
|
2428
|
+
* ```
|
|
2429
|
+
*
|
|
2430
|
+
* @template OverrideStateType - The specific type of state the middleware listener operates on.
|
|
2431
|
+
* @template OverrideDispatchType - The specific type of the dispatch function.
|
|
2432
|
+
* @template OverrideExtraArgument - The specific type of the extra object.
|
|
2433
|
+
*
|
|
2434
|
+
* @since 2.1.0
|
|
2435
|
+
*/
|
|
2436
|
+
withTypes: <OverrideStateType extends StateType, OverrideDispatchType extends Dispatch = ThunkDispatch$1<OverrideStateType, unknown, UnknownAction>, OverrideExtraArgument = unknown>() => TypedAddListener<OverrideStateType, OverrideDispatchType, OverrideExtraArgument>;
|
|
2470
2437
|
};
|
|
2471
2438
|
/**
|
|
2472
2439
|
* A "pre-typed" version of `removeListenerAction`, so the listener args are well-typed
|
|
2473
2440
|
*
|
|
2474
2441
|
* @public
|
|
2475
2442
|
*/
|
|
2476
|
-
type TypedRemoveListener<StateType, DispatchType extends Dispatch = ThunkDispatch<StateType, unknown, UnknownAction>, ExtraArgument = unknown, Payload = ListenerEntry<StateType, DispatchType>, T extends string = 'listenerMiddleware/remove'> = BaseActionCreator<Payload, T> & AddListenerOverloads<PayloadAction<Payload, T>, StateType, DispatchType, ExtraArgument, UnsubscribeListenerOptions> & {
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2443
|
+
type TypedRemoveListener<StateType, DispatchType extends Dispatch = ThunkDispatch$1<StateType, unknown, UnknownAction>, ExtraArgument = unknown, Payload = ListenerEntry<StateType, DispatchType>, T extends string = 'listenerMiddleware/remove'> = BaseActionCreator<Payload, T> & AddListenerOverloads<PayloadAction<Payload, T>, StateType, DispatchType, ExtraArgument, UnsubscribeListenerOptions> & {
|
|
2444
|
+
/**
|
|
2445
|
+
* Creates a "pre-typed" version of `removeListener`
|
|
2446
|
+
* where the `state`, `dispatch` and `extra` types are predefined.
|
|
2447
|
+
*
|
|
2448
|
+
* This allows you to set the `state`, `dispatch` and `extra` types once,
|
|
2449
|
+
* eliminating the need to specify them with every `removeListener` call.
|
|
2450
|
+
*
|
|
2451
|
+
* @returns A pre-typed `removeListener` with the state, dispatch and extra
|
|
2452
|
+
* types already defined.
|
|
2453
|
+
*
|
|
2454
|
+
* @example
|
|
2455
|
+
* ```ts
|
|
2456
|
+
* import { removeListener } from '@reduxjs/toolkit'
|
|
2457
|
+
*
|
|
2458
|
+
* export const removeAppListener = removeListener.withTypes<
|
|
2459
|
+
* RootState,
|
|
2460
|
+
* AppDispatch,
|
|
2461
|
+
* ExtraArguments
|
|
2462
|
+
* >()
|
|
2463
|
+
* ```
|
|
2464
|
+
*
|
|
2465
|
+
* @template OverrideStateType - The specific type of state the middleware listener operates on.
|
|
2466
|
+
* @template OverrideDispatchType - The specific type of the dispatch function.
|
|
2467
|
+
* @template OverrideExtraArgument - The specific type of the extra object.
|
|
2468
|
+
*
|
|
2469
|
+
* @since 2.1.0
|
|
2470
|
+
*/
|
|
2471
|
+
withTypes: <OverrideStateType extends StateType, OverrideDispatchType extends Dispatch = ThunkDispatch$1<OverrideStateType, unknown, UnknownAction>, OverrideExtraArgument = unknown>() => TypedRemoveListener<OverrideStateType, OverrideDispatchType, OverrideExtraArgument>;
|
|
2505
2472
|
};
|
|
2506
2473
|
/**
|
|
2507
2474
|
* A "pre-typed" version of `middleware.startListening`, so the listener args are well-typed
|
|
2508
2475
|
*
|
|
2509
2476
|
* @public
|
|
2510
2477
|
*/
|
|
2511
|
-
type TypedStartListening<StateType, DispatchType extends Dispatch = ThunkDispatch<StateType, unknown, UnknownAction>, ExtraArgument = unknown> = AddListenerOverloads<UnsubscribeListener, StateType, DispatchType, ExtraArgument> & {
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2478
|
+
type TypedStartListening<StateType, DispatchType extends Dispatch = ThunkDispatch$1<StateType, unknown, UnknownAction>, ExtraArgument = unknown> = AddListenerOverloads<UnsubscribeListener, StateType, DispatchType, ExtraArgument> & {
|
|
2479
|
+
/**
|
|
2480
|
+
* Creates a "pre-typed" version of
|
|
2481
|
+
* {@linkcode ListenerMiddlewareInstance.startListening | startListening}
|
|
2482
|
+
* where the `state`, `dispatch` and `extra` types are predefined.
|
|
2483
|
+
*
|
|
2484
|
+
* This allows you to set the `state`, `dispatch` and `extra` types once,
|
|
2485
|
+
* eliminating the need to specify them with every
|
|
2486
|
+
* {@linkcode ListenerMiddlewareInstance.startListening | startListening}
|
|
2487
|
+
* call.
|
|
2488
|
+
*
|
|
2489
|
+
* @returns A pre-typed `startListening` with the state, dispatch and extra types already defined.
|
|
2490
|
+
*
|
|
2491
|
+
* @example
|
|
2492
|
+
* ```ts
|
|
2493
|
+
* import { createListenerMiddleware } from '@reduxjs/toolkit'
|
|
2494
|
+
*
|
|
2495
|
+
* const listenerMiddleware = createListenerMiddleware()
|
|
2496
|
+
*
|
|
2497
|
+
* export const startAppListening = listenerMiddleware.startListening.withTypes<
|
|
2498
|
+
* RootState,
|
|
2499
|
+
* AppDispatch,
|
|
2500
|
+
* ExtraArguments
|
|
2501
|
+
* >()
|
|
2502
|
+
* ```
|
|
2503
|
+
*
|
|
2504
|
+
* @template OverrideStateType - The specific type of state the middleware listener operates on.
|
|
2505
|
+
* @template OverrideDispatchType - The specific type of the dispatch function.
|
|
2506
|
+
* @template OverrideExtraArgument - The specific type of the extra object.
|
|
2507
|
+
*
|
|
2508
|
+
* @since 2.1.0
|
|
2509
|
+
*/
|
|
2510
|
+
withTypes: <OverrideStateType extends StateType, OverrideDispatchType extends Dispatch = ThunkDispatch$1<OverrideStateType, unknown, UnknownAction>, OverrideExtraArgument = unknown>() => TypedStartListening<OverrideStateType, OverrideDispatchType, OverrideExtraArgument>;
|
|
2544
2511
|
};
|
|
2545
2512
|
/**
|
|
2546
2513
|
* A "pre-typed" version of `middleware.stopListening`, so the listener args are well-typed
|
|
2547
2514
|
*
|
|
2548
2515
|
* @public
|
|
2549
2516
|
*/
|
|
2550
|
-
type TypedStopListening<StateType, DispatchType extends Dispatch = ThunkDispatch<StateType, unknown, UnknownAction>, ExtraArgument = unknown> = RemoveListenerOverloads<StateType, DispatchType, ExtraArgument> & {
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2517
|
+
type TypedStopListening<StateType, DispatchType extends Dispatch = ThunkDispatch$1<StateType, unknown, UnknownAction>, ExtraArgument = unknown> = RemoveListenerOverloads<StateType, DispatchType, ExtraArgument> & {
|
|
2518
|
+
/**
|
|
2519
|
+
* Creates a "pre-typed" version of
|
|
2520
|
+
* {@linkcode ListenerMiddlewareInstance.stopListening | stopListening}
|
|
2521
|
+
* where the `state`, `dispatch` and `extra` types are predefined.
|
|
2522
|
+
*
|
|
2523
|
+
* This allows you to set the `state`, `dispatch` and `extra` types once,
|
|
2524
|
+
* eliminating the need to specify them with every
|
|
2525
|
+
* {@linkcode ListenerMiddlewareInstance.stopListening | stopListening} call.
|
|
2526
|
+
*
|
|
2527
|
+
* @returns A pre-typed `stopListening` with the state, dispatch and extra types already defined.
|
|
2528
|
+
*
|
|
2529
|
+
* @example
|
|
2530
|
+
* ```ts
|
|
2531
|
+
* import { createListenerMiddleware } from '@reduxjs/toolkit'
|
|
2532
|
+
*
|
|
2533
|
+
* const listenerMiddleware = createListenerMiddleware()
|
|
2534
|
+
*
|
|
2535
|
+
* export const stopAppListening = listenerMiddleware.stopListening.withTypes<
|
|
2536
|
+
* RootState,
|
|
2537
|
+
* AppDispatch,
|
|
2538
|
+
* ExtraArguments
|
|
2539
|
+
* >()
|
|
2540
|
+
* ```
|
|
2541
|
+
*
|
|
2542
|
+
* @template OverrideStateType - The specific type of state the middleware listener operates on.
|
|
2543
|
+
* @template OverrideDispatchType - The specific type of the dispatch function.
|
|
2544
|
+
* @template OverrideExtraArgument - The specific type of the extra object.
|
|
2545
|
+
*
|
|
2546
|
+
* @since 2.1.0
|
|
2547
|
+
*/
|
|
2548
|
+
withTypes: <OverrideStateType extends StateType, OverrideDispatchType extends Dispatch = ThunkDispatch$1<OverrideStateType, unknown, UnknownAction>, OverrideExtraArgument = unknown>() => TypedStopListening<OverrideStateType, OverrideDispatchType, OverrideExtraArgument>;
|
|
2582
2549
|
};
|
|
2583
2550
|
/**
|
|
2584
2551
|
* Internal Types
|
|
@@ -2589,21 +2556,22 @@ type TypedStopListening<StateType, DispatchType extends Dispatch = ThunkDispatch
|
|
|
2589
2556
|
* @internal
|
|
2590
2557
|
*/
|
|
2591
2558
|
type ListenerEntry<State = unknown, DispatchType extends Dispatch = Dispatch> = {
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2559
|
+
id: string;
|
|
2560
|
+
effect: ListenerEffect<any, State, DispatchType>;
|
|
2561
|
+
unsubscribe: () => void;
|
|
2562
|
+
pending: Set<AbortController>;
|
|
2563
|
+
type?: string;
|
|
2564
|
+
predicate: ListenerPredicate<UnknownAction, State>;
|
|
2598
2565
|
};
|
|
2599
2566
|
/**
|
|
2600
2567
|
* Utility Types
|
|
2601
2568
|
*/
|
|
2602
2569
|
/** @public */
|
|
2603
|
-
type GuardedType<T> = T extends (x: any, ...args: any[]) => x is infer T ? T : never;
|
|
2570
|
+
type GuardedType<T> = T extends ((x: any, ...args: any[]) => x is infer T) ? T : never;
|
|
2604
2571
|
/** @public */
|
|
2605
2572
|
type ListenerPredicateGuardedActionType<T> = T extends ListenerPredicate<infer ActionType, any> ? ActionType : never;
|
|
2606
|
-
|
|
2573
|
+
//#endregion
|
|
2574
|
+
//#region src/listenerMiddleware/index.d.ts
|
|
2607
2575
|
/**
|
|
2608
2576
|
* @public
|
|
2609
2577
|
*/
|
|
@@ -2619,40 +2587,43 @@ declare const removeListener: TypedRemoveListener<unknown>;
|
|
|
2619
2587
|
/**
|
|
2620
2588
|
* @public
|
|
2621
2589
|
*/
|
|
2622
|
-
declare const createListenerMiddleware: <StateType = unknown, DispatchType extends Dispatch<Action> = ThunkDispatch<StateType, unknown, UnknownAction>, ExtraArgument = unknown>(middlewareOptions?: CreateListenerMiddlewareOptions<ExtraArgument>) => ListenerMiddlewareInstance<StateType, DispatchType, ExtraArgument>;
|
|
2623
|
-
|
|
2590
|
+
declare const createListenerMiddleware: <StateType = unknown, DispatchType extends Dispatch<Action> = ThunkDispatch$1<StateType, unknown, UnknownAction>, ExtraArgument = unknown>(middlewareOptions?: CreateListenerMiddlewareOptions<ExtraArgument>) => ListenerMiddlewareInstance<StateType, DispatchType, ExtraArgument>;
|
|
2591
|
+
//#endregion
|
|
2592
|
+
//#region src/dynamicMiddleware/types.d.ts
|
|
2624
2593
|
type MiddlewareApiConfig = {
|
|
2625
|
-
|
|
2626
|
-
|
|
2594
|
+
state?: unknown;
|
|
2595
|
+
dispatch?: Dispatch;
|
|
2627
2596
|
};
|
|
2628
2597
|
type GetDispatchType<MiddlewareApiConfig> = MiddlewareApiConfig extends {
|
|
2629
|
-
|
|
2598
|
+
dispatch: infer DispatchType;
|
|
2630
2599
|
} ? FallbackIfUnknown<DispatchType, Dispatch> : Dispatch;
|
|
2631
2600
|
type AddMiddleware<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = {
|
|
2632
|
-
|
|
2633
|
-
|
|
2601
|
+
(...middlewares: Middleware<any, State, DispatchType>[]): void;
|
|
2602
|
+
withTypes<MiddlewareConfig extends MiddlewareApiConfig>(): AddMiddleware<GetState<MiddlewareConfig>, GetDispatchType<MiddlewareConfig>>;
|
|
2634
2603
|
};
|
|
2635
2604
|
type WithMiddleware<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = BaseActionCreator<Middleware<any, State, DispatchType>[], 'dynamicMiddleware/add', {
|
|
2636
|
-
|
|
2605
|
+
instanceId: string;
|
|
2637
2606
|
}> & {
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2607
|
+
<Middlewares extends Middleware<any, State, DispatchType>[]>(...middlewares: Middlewares): PayloadAction<Middlewares, 'dynamicMiddleware/add', {
|
|
2608
|
+
instanceId: string;
|
|
2609
|
+
}>;
|
|
2610
|
+
withTypes<MiddlewareConfig extends MiddlewareApiConfig>(): WithMiddleware<GetState<MiddlewareConfig>, GetDispatchType<MiddlewareConfig>>;
|
|
2642
2611
|
};
|
|
2643
2612
|
interface DynamicDispatch {
|
|
2644
|
-
|
|
2613
|
+
<Middlewares extends Middleware<any>[]>(action: PayloadAction<Middlewares, 'dynamicMiddleware/add'>): ExtractDispatchExtensions<Middlewares> & this;
|
|
2645
2614
|
}
|
|
2646
2615
|
type DynamicMiddleware<State = unknown, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = Middleware<DynamicDispatch, State, DispatchType>;
|
|
2647
2616
|
type DynamicMiddlewareInstance<State = unknown, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = {
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2617
|
+
middleware: DynamicMiddleware<State, DispatchType>;
|
|
2618
|
+
addMiddleware: AddMiddleware<State, DispatchType>;
|
|
2619
|
+
withMiddleware: WithMiddleware<State, DispatchType>;
|
|
2620
|
+
instanceId: string;
|
|
2652
2621
|
};
|
|
2653
|
-
|
|
2622
|
+
//#endregion
|
|
2623
|
+
//#region src/dynamicMiddleware/index.d.ts
|
|
2654
2624
|
declare const createDynamicMiddleware: <State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>>() => DynamicMiddlewareInstance<State, DispatchType>;
|
|
2655
|
-
|
|
2625
|
+
//#endregion
|
|
2626
|
+
//#region src/formatProdErrorMessage.d.ts
|
|
2656
2627
|
/**
|
|
2657
2628
|
* Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
|
|
2658
2629
|
*
|
|
@@ -2661,5 +2632,5 @@ declare const createDynamicMiddleware: <State = any, DispatchType extends Dispat
|
|
|
2661
2632
|
* @param {number} code
|
|
2662
2633
|
*/
|
|
2663
2634
|
declare function formatProdErrorMessage(code: number): string;
|
|
2664
|
-
|
|
2665
|
-
export { type ActionCreatorInvariantMiddlewareOptions, type ActionCreatorWithNonInferrablePayload, type ActionCreatorWithOptionalPayload, type ActionCreatorWithPayload, type ActionCreatorWithPreparedPayload, type ActionCreatorWithoutPayload, type ActionMatchingAllOf, type ActionMatchingAnyOf, type ActionReducerMapBuilder, type Actions, type AddMiddleware, type AnyListenerPredicate, type AsyncTaskExecutor, type AsyncThunk, type AsyncThunkAction, type AsyncThunkConfig, type AsyncThunkDispatchConfig, type AsyncThunkOptions, type AsyncThunkPayloadCreator, type AsyncThunkPayloadCreatorReturnValue, type AsyncThunkReducers, type AutoBatchOptions, type CaseReducer, type CaseReducerActions, type CaseReducerWithPrepare, type CaseReducers, type CombinedSliceReducer, type Comparer, type ConfigureStoreOptions, type CreateAsyncThunkFunction, type CreateListenerMiddlewareOptions, type CreateSliceOptions, type DevToolsEnhancerOptions, type DynamicDispatch, type DynamicMiddlewareInstance, type EnhancedStore, type EntityAdapter, type EntityId, type EntitySelectors, type EntityState, type EntityStateAdapter, type ForkedTask, type ForkedTaskAPI, type ForkedTaskExecutor, type GetDispatchType as GetDispatch, type GetState, type GetThunkAPI, type IdSelector, type ImmutableStateInvariantMiddlewareOptions, type ListenerEffect, type ListenerEffectAPI, type ListenerErrorHandler, type ListenerMiddleware, type ListenerMiddlewareInstance, type MiddlewareApiConfig, type PayloadAction, type PayloadActionCreator, type PrepareAction, type ReducerCreators, ReducerType, SHOULD_AUTOBATCH, type SafePromise, type SerializableStateInvariantMiddlewareOptions, type SerializedError, type Slice, type SliceCaseReducers, type SliceSelectors, type SyncTaskExecutor, type ExtractDispatchExtensions as TSHelpersExtractDispatchExtensions, TaskAbortError, type TaskCancelled, type TaskRejected, type TaskResolved, type TaskResult, Tuple, type TypedAddListener, type TypedRemoveListener, type TypedStartListening, type TypedStopListening, type UnsubscribeListener, type UnsubscribeListenerOptions, type Update, type ValidateSliceCaseReducers, type WithSlice, type WithSlicePreloadedState, addListener, asyncThunkCreator, autoBatchEnhancer, buildCreateSlice, clearAllListeners, combineSlices, configureStore, createAction, createActionCreatorInvariantMiddleware, createAsyncThunk, createDraftSafeSelector, createDraftSafeSelectorCreator, createDynamicMiddleware, createEntityAdapter, createImmutableStateInvariantMiddleware, createListenerMiddleware, createReducer, createSerializableStateInvariantMiddleware, createSlice, findNonSerializableValue, formatProdErrorMessage, isActionCreator, isAllOf, isAnyOf, isAsyncThunkAction, isFSA as isFluxStandardAction, isFulfilled, isImmutableDefault, isPending, isPlain, isRejected, isRejectedWithValue, miniSerializeError, nanoid, prepareAutoBatched, removeListener, unwrapResult };
|
|
2635
|
+
//#endregion
|
|
2636
|
+
export { type ActionCreatorInvariantMiddlewareOptions, type ActionCreatorWithNonInferrablePayload, type ActionCreatorWithOptionalPayload, type ActionCreatorWithPayload, type ActionCreatorWithPreparedPayload, type ActionCreatorWithoutPayload, type ActionMatchingAllOf, type ActionMatchingAnyOf, type ActionReducerMapBuilder, type Actions, type AddMiddleware, type AnyListenerPredicate, type AsyncTaskExecutor, type AsyncThunk, type AsyncThunkAction, type AsyncThunkConfig, type AsyncThunkDispatchConfig, type AsyncThunkOptions, type AsyncThunkPayloadCreator, type AsyncThunkPayloadCreatorReturnValue, type AsyncThunkReducers, type AutoBatchOptions, type CaseReducer, type CaseReducerActions, type CaseReducerWithPrepare, type CaseReducers, type CombinedSliceReducer, type Comparer, type ConfigureStoreOptions, type CreateAsyncThunkFunction, type CreateListenerMiddlewareOptions, type CreateSliceOptions, type DevToolsEnhancerOptions, type Draft, type DynamicDispatch, type DynamicMiddlewareInstance, type EnhancedStore, type EntityAdapter, type EntityId, type EntitySelectors, type EntityState, type EntityStateAdapter, type ForkedTask, type ForkedTaskAPI, type ForkedTaskExecutor, type GetDispatchType as GetDispatch, type GetState, type GetThunkAPI, type IdSelector, type ImmutableStateInvariantMiddlewareOptions, type ListenerEffect, type ListenerEffectAPI, type ListenerErrorHandler, type ListenerMiddleware, type ListenerMiddlewareInstance, type MiddlewareApiConfig, type OutputSelector, type PayloadAction, type PayloadActionCreator, type PrepareAction, type ReducerCreators, ReducerType, SHOULD_AUTOBATCH, type SafePromise, type Selector, type SerializableStateInvariantMiddlewareOptions, type SerializedError, type Slice$1 as Slice, type SliceCaseReducers, type SliceSelectors, type SyncTaskExecutor, type ExtractDispatchExtensions as TSHelpersExtractDispatchExtensions, TaskAbortError, type TaskCancelled, type TaskRejected, type TaskResolved, type TaskResult, type ThunkAction, type ThunkDispatch, type ThunkMiddleware, Tuple, type TypedAddListener, type TypedRemoveListener, type TypedStartListening, type TypedStopListening, type UnsubscribeListener, type UnsubscribeListenerOptions, type Update, type ValidateSliceCaseReducers, type WithSlice, type WithSlicePreloadedState, type WritableDraft, addListener, asyncThunkCreator, autoBatchEnhancer, buildCreateSlice, clearAllListeners, combineSlices, configureStore, createAction, createActionCreatorInvariantMiddleware, createAsyncThunk, createDraftSafeSelector, createDraftSafeSelectorCreator, createDynamicMiddleware, createEntityAdapter, createImmutableStateInvariantMiddleware, createListenerMiddleware, createNextState, createReducer, createSelector, createSelectorCreator, createSerializableStateInvariantMiddleware, createSlice, current, findNonSerializableValue, formatProdErrorMessage, freeze, isActionCreator, isAllOf, isAnyOf, isAsyncThunkAction, isDraft, isFSA as isFluxStandardAction, isFulfilled, isImmutableDefault, isPending, isPlain, isRejected, isRejectedWithValue, lruMemoize, miniSerializeError, nanoid, original, prepareAutoBatched, removeListener, unwrapResult, weakMapMemoize };
|