state-decorator 7.0.0-beta.9-dev → 7.0.0-rc2
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 +55 -24
- package/development.d.ts +10 -0
- package/development.js +2 -0
- package/development.js.map +1 -0
- package/graph.d.ts +8 -0
- package/helpers.js +1 -174
- package/helpers.js.map +1 -1
- package/impl.d.ts +20 -32
- package/impl.js +1 -996
- package/impl.js.map +1 -1
- package/index.d.ts +10 -11
- package/index.js +1 -1044
- package/index.js.map +1 -1
- package/middlewares.d.ts +0 -23
- package/middlewares.js +1 -526
- package/middlewares.js.map +1 -1
- package/package.json +2 -2
- package/shallow.d.ts +0 -14
- package/test.d.ts +7 -21
- package/test.js +1 -358
- package/test.js.map +1 -1
- package/types.d.ts +73 -72
- package/v5.d.ts +5 -18
- package/v5.js +1 -322
- package/v5.js.map +1 -1
- package/v5_test.d.ts +4 -17
- package/v5_test.js +1 -416
- package/v5_test.js.map +1 -1
- package/v5_types.d.ts +15 -29
- package/v6.d.ts +7 -3
- package/v6.js +1 -120
- package/v6.js.map +1 -1
- package/es/helpers.d.ts +0 -66
- package/es/helpers.js +0 -163
- package/es/helpers.js.map +0 -1
- package/es/impl.d.ts +0 -209
- package/es/impl.js +0 -964
- package/es/impl.js.map +0 -1
- package/es/index.d.ts +0 -164
- package/es/index.js +0 -1014
- package/es/index.js.map +0 -1
- package/es/middlewares.d.ts +0 -26
- package/es/middlewares.js +0 -520
- package/es/middlewares.js.map +0 -1
- package/es/shallow.d.ts +0 -15
- package/es/test.d.ts +0 -136
- package/es/test.js +0 -350
- package/es/test.js.map +0 -1
- package/es/types.d.ts +0 -381
- package/es/v5.d.ts +0 -58
- package/es/v5.js +0 -302
- package/es/v5.js.map +0 -1
- package/es/v5_test.d.ts +0 -70
- package/es/v5_test.js +0 -393
- package/es/v5_test.js.map +0 -1
- package/es/v5_types.d.ts +0 -227
- package/es/v6.d.ts +0 -17
- package/es/v6.js +0 -97
- package/es/v6.js.map +0 -1
package/es/v5_test.js
DELETED
|
@@ -1,393 +0,0 @@
|
|
|
1
|
-
import { ConflictPolicy } from './index';
|
|
2
|
-
export { ConflictPolicy, setGlobalConfig } from './index';
|
|
3
|
-
import { isSimpleSyncAction, isSyncAction as isSyncAction$1, isAsyncAction as isAsyncAction$1, isAsyncGetPromiseAction, isAsyncGetPromiseGetAction } from './impl';
|
|
4
|
-
|
|
5
|
-
/*! *****************************************************************************
|
|
6
|
-
Copyright (c) Microsoft Corporation.
|
|
7
|
-
|
|
8
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
9
|
-
purpose with or without fee is hereby granted.
|
|
10
|
-
|
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
12
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
13
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
18
|
-
***************************************************************************** */
|
|
19
|
-
|
|
20
|
-
var __assign = function() {
|
|
21
|
-
__assign = Object.assign || function __assign(t) {
|
|
22
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
23
|
-
s = arguments[i];
|
|
24
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
25
|
-
}
|
|
26
|
-
return t;
|
|
27
|
-
};
|
|
28
|
-
return __assign.apply(this, arguments);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
function __spreadArray(to, from, pack) {
|
|
32
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
33
|
-
if (ar || !(i in from)) {
|
|
34
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
35
|
-
ar[i] = from[i];
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/*! *****************************************************************************
|
|
42
|
-
Copyright (c) GlobalSport SAS.
|
|
43
|
-
|
|
44
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
45
|
-
purpose with or without fee is hereby granted.
|
|
46
|
-
|
|
47
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
48
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
49
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
50
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
51
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
52
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
53
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
54
|
-
***************************************************************************** */
|
|
55
|
-
/**
|
|
56
|
-
* Type guard function to test if an action is a asynchronous action.
|
|
57
|
-
*/
|
|
58
|
-
function isAsyncAction(action) {
|
|
59
|
-
return !(action instanceof Function) && (action.hasOwnProperty('promise') || action.hasOwnProperty('promiseGet'));
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Type guard function to test if an action is a asynchronous action.
|
|
63
|
-
*/
|
|
64
|
-
function isAsyncPromiseGetAction(action) {
|
|
65
|
-
return !(action instanceof Function) && !(action.hasOwnProperty('promise') && action.hasOwnProperty('promiseGet'));
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Type guard function to test if an action is a synchronous action.
|
|
69
|
-
*/
|
|
70
|
-
function isSyncAction(action) {
|
|
71
|
-
return action instanceof Function;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Type guard function to test if an action is a synchronous action.
|
|
75
|
-
*/
|
|
76
|
-
function isAdvancedSyncAction(action) {
|
|
77
|
-
return !(action instanceof Function) && !action.hasOwnProperty('promise') && !action.hasOwnProperty('promiseGet');
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* @private
|
|
81
|
-
*/
|
|
82
|
-
function computeAsyncActionInput(action) {
|
|
83
|
-
if ('promiseGet' in action) {
|
|
84
|
-
return __assign(__assign({}, action), { promise: action.promiseGet, retryCount: 3, conflictPolicy: ConflictPolicy.REUSE });
|
|
85
|
-
}
|
|
86
|
-
return action;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Utility to test an asynchronous action.
|
|
90
|
-
* @param action The action to test
|
|
91
|
-
* @param test The test function that takes the discrimined action type and cam return a promise
|
|
92
|
-
*/
|
|
93
|
-
function testAsyncAction(action, test) {
|
|
94
|
-
if (isAsyncAction(action)) {
|
|
95
|
-
return test(computeAsyncActionInput(action));
|
|
96
|
-
}
|
|
97
|
-
return Promise.reject(new Error('This action is not an asynchronous action'));
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Utility to test an synchronous action.
|
|
101
|
-
* @param action The action to test
|
|
102
|
-
* @param test The test function that takes the discrimined action type and cam return a promise
|
|
103
|
-
*/
|
|
104
|
-
function testSyncAction(action, test) {
|
|
105
|
-
if (isSyncAction(action)) {
|
|
106
|
-
return test(action);
|
|
107
|
-
}
|
|
108
|
-
return Promise.reject(new Error('This action is not a synchronous action'));
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Utility to test an advanced synchronous action.
|
|
112
|
-
* @param action The action to test
|
|
113
|
-
* @param test The test function that takes the discrimined action type and cam return a promise
|
|
114
|
-
*/
|
|
115
|
-
function testAdvancedSyncAction(action, test) {
|
|
116
|
-
if (isAdvancedSyncAction(action)) {
|
|
117
|
-
return test(action);
|
|
118
|
-
}
|
|
119
|
-
return Promise.reject(new Error('This action is not a synchronous advanced action'));
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Utility to test a V6 synchronous action using v5 test.
|
|
123
|
-
* @param action The action to test
|
|
124
|
-
* @param test The test function that takes the discrimined action type and cam return a promise
|
|
125
|
-
*/
|
|
126
|
-
function testV6SyncAction(action, test) {
|
|
127
|
-
if (isSimpleSyncAction(action)) {
|
|
128
|
-
var decoratedAction = function (s, args, p) {
|
|
129
|
-
return mergeState(s, action({
|
|
130
|
-
s: s,
|
|
131
|
-
args: args,
|
|
132
|
-
p: p,
|
|
133
|
-
ds: null,
|
|
134
|
-
derived: null,
|
|
135
|
-
state: s,
|
|
136
|
-
props: p,
|
|
137
|
-
promiseId: null,
|
|
138
|
-
}));
|
|
139
|
-
};
|
|
140
|
-
test(decoratedAction);
|
|
141
|
-
return Promise.resolve();
|
|
142
|
-
}
|
|
143
|
-
return Promise.reject(new Error('This action is not a synchronous action'));
|
|
144
|
-
}
|
|
145
|
-
function mergeState(s, newState) {
|
|
146
|
-
return newState == null ? null : __assign(__assign({}, s), newState);
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Utility to test a V6 synchronous action using v5 test.
|
|
150
|
-
* @param actionIn The action to test
|
|
151
|
-
* @param test The test function that takes the discrimined action type and cam return a promise
|
|
152
|
-
*/
|
|
153
|
-
function testV6AdvancedSyncAction(actionIn, test) {
|
|
154
|
-
if (isSyncAction$1(actionIn)) {
|
|
155
|
-
var decoratedAction = {
|
|
156
|
-
action: function (s, args, p) {
|
|
157
|
-
return mergeState(s, actionIn.effects({
|
|
158
|
-
s: s,
|
|
159
|
-
args: args,
|
|
160
|
-
p: p,
|
|
161
|
-
ds: null,
|
|
162
|
-
derived: null,
|
|
163
|
-
state: s,
|
|
164
|
-
props: p,
|
|
165
|
-
res: null,
|
|
166
|
-
result: null,
|
|
167
|
-
promiseId: null,
|
|
168
|
-
}));
|
|
169
|
-
},
|
|
170
|
-
onActionDone: function (s, args, p, a, notifyWarning) {
|
|
171
|
-
actionIn.sideEffects({
|
|
172
|
-
s: s,
|
|
173
|
-
args: args,
|
|
174
|
-
p: p,
|
|
175
|
-
a: a,
|
|
176
|
-
notifyWarning: notifyWarning,
|
|
177
|
-
ds: null,
|
|
178
|
-
derived: null,
|
|
179
|
-
state: s,
|
|
180
|
-
props: p,
|
|
181
|
-
actions: a,
|
|
182
|
-
res: null,
|
|
183
|
-
result: null,
|
|
184
|
-
promiseId: null,
|
|
185
|
-
clearError: function () { },
|
|
186
|
-
});
|
|
187
|
-
},
|
|
188
|
-
};
|
|
189
|
-
test(decoratedAction);
|
|
190
|
-
return Promise.resolve();
|
|
191
|
-
}
|
|
192
|
-
return Promise.reject(new Error('This action is not a synchronous action'));
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Utility to test a V6 synchronous action using v5 test.
|
|
196
|
-
* @param actionIn The action to test
|
|
197
|
-
* @param test The test function that takes the discrimined action type and cam return a promise
|
|
198
|
-
*/
|
|
199
|
-
function testV6AsyncAction(actionIn, test) {
|
|
200
|
-
if (isAsyncAction$1(actionIn)) {
|
|
201
|
-
var decoratedAction = {
|
|
202
|
-
abortable: actionIn.abortable,
|
|
203
|
-
rejectPromiseOnError: actionIn.rejectPromiseOnError,
|
|
204
|
-
retryCount: actionIn.retryCount,
|
|
205
|
-
retryDelaySeed: actionIn.retryDelaySeed,
|
|
206
|
-
isTriggerRetryError: actionIn.isTriggerRetryError,
|
|
207
|
-
conflictPolicy: actionIn.conflictPolicy,
|
|
208
|
-
getPromiseId: actionIn.getPromiseId,
|
|
209
|
-
promise: function (args, s, p, a, abortSignal) {
|
|
210
|
-
if (isAsyncGetPromiseAction(actionIn)) {
|
|
211
|
-
return actionIn.getPromise({
|
|
212
|
-
s: s,
|
|
213
|
-
args: args,
|
|
214
|
-
p: p,
|
|
215
|
-
a: a,
|
|
216
|
-
abortSignal: abortSignal,
|
|
217
|
-
ds: null,
|
|
218
|
-
derived: null,
|
|
219
|
-
state: s,
|
|
220
|
-
props: p,
|
|
221
|
-
actions: a,
|
|
222
|
-
promiseId: null,
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
return actionIn.getGetPromise({
|
|
226
|
-
s: s,
|
|
227
|
-
args: args,
|
|
228
|
-
p: p,
|
|
229
|
-
a: a,
|
|
230
|
-
abortSignal: abortSignal,
|
|
231
|
-
ds: null,
|
|
232
|
-
derived: null,
|
|
233
|
-
state: s,
|
|
234
|
-
props: p,
|
|
235
|
-
actions: a,
|
|
236
|
-
promiseId: null,
|
|
237
|
-
});
|
|
238
|
-
},
|
|
239
|
-
promiseGet: function (args, s, p, a, abortSignal) {
|
|
240
|
-
if (isAsyncGetPromiseGetAction(actionIn)) {
|
|
241
|
-
return actionIn.getGetPromise({
|
|
242
|
-
s: s,
|
|
243
|
-
args: args,
|
|
244
|
-
p: p,
|
|
245
|
-
a: a,
|
|
246
|
-
abortSignal: abortSignal,
|
|
247
|
-
ds: null,
|
|
248
|
-
derived: null,
|
|
249
|
-
state: s,
|
|
250
|
-
props: p,
|
|
251
|
-
actions: a,
|
|
252
|
-
promiseId: null,
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
return null;
|
|
256
|
-
},
|
|
257
|
-
reducer: function (s, res, args, p) {
|
|
258
|
-
return actionIn.effects
|
|
259
|
-
? mergeState(s, actionIn.effects({
|
|
260
|
-
s: s,
|
|
261
|
-
args: args,
|
|
262
|
-
p: p,
|
|
263
|
-
res: res,
|
|
264
|
-
ds: null,
|
|
265
|
-
derived: null,
|
|
266
|
-
state: s,
|
|
267
|
-
props: p,
|
|
268
|
-
result: res,
|
|
269
|
-
promiseId: null,
|
|
270
|
-
}))
|
|
271
|
-
: null;
|
|
272
|
-
},
|
|
273
|
-
preReducer: function (s, args, p) {
|
|
274
|
-
return actionIn.preEffects
|
|
275
|
-
? mergeState(s, actionIn.preEffects({
|
|
276
|
-
s: s,
|
|
277
|
-
args: args,
|
|
278
|
-
p: p,
|
|
279
|
-
ds: null,
|
|
280
|
-
derived: null,
|
|
281
|
-
state: s,
|
|
282
|
-
props: p,
|
|
283
|
-
promiseId: null,
|
|
284
|
-
}))
|
|
285
|
-
: null;
|
|
286
|
-
},
|
|
287
|
-
optimisticReducer: function (s, args, p) {
|
|
288
|
-
var _a;
|
|
289
|
-
return actionIn.optimisticEffects
|
|
290
|
-
? mergeState(s, actionIn.optimisticEffects({
|
|
291
|
-
s: s,
|
|
292
|
-
args: args,
|
|
293
|
-
p: p,
|
|
294
|
-
ds: null,
|
|
295
|
-
derived: null,
|
|
296
|
-
state: s,
|
|
297
|
-
props: p,
|
|
298
|
-
promiseId: (_a = actionIn.getPromiseId) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spreadArray([actionIn], args, false)),
|
|
299
|
-
}))
|
|
300
|
-
: null;
|
|
301
|
-
},
|
|
302
|
-
errorReducer: function (s, err, args, p) {
|
|
303
|
-
var _a;
|
|
304
|
-
return actionIn.errorEffects
|
|
305
|
-
? mergeState(s, actionIn.errorEffects({
|
|
306
|
-
s: s,
|
|
307
|
-
args: args,
|
|
308
|
-
p: p,
|
|
309
|
-
err: err,
|
|
310
|
-
ds: null,
|
|
311
|
-
derived: null,
|
|
312
|
-
state: s,
|
|
313
|
-
props: p,
|
|
314
|
-
error: err,
|
|
315
|
-
promiseId: (_a = actionIn.getPromiseId) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spreadArray([actionIn], args, false)),
|
|
316
|
-
}))
|
|
317
|
-
: null;
|
|
318
|
-
},
|
|
319
|
-
onDone: function (s, res, args, p, a, notifyWarning) {
|
|
320
|
-
var _a, _b;
|
|
321
|
-
(_a = actionIn.sideEffects) === null || _a === void 0 ? void 0 : _a.call(actionIn, {
|
|
322
|
-
s: s,
|
|
323
|
-
args: args,
|
|
324
|
-
p: p,
|
|
325
|
-
a: a,
|
|
326
|
-
res: res,
|
|
327
|
-
notifyWarning: notifyWarning,
|
|
328
|
-
ds: null,
|
|
329
|
-
derived: null,
|
|
330
|
-
state: s,
|
|
331
|
-
props: p,
|
|
332
|
-
actions: a,
|
|
333
|
-
result: res,
|
|
334
|
-
promiseId: (_b = actionIn.getPromiseId) === null || _b === void 0 ? void 0 : _b.call.apply(_b, __spreadArray([actionIn], args, false)),
|
|
335
|
-
clearError: function () { },
|
|
336
|
-
});
|
|
337
|
-
},
|
|
338
|
-
onFail: function (s, err, args, p, a, notifyWarning) {
|
|
339
|
-
var _a, _b;
|
|
340
|
-
(_a = actionIn.errorSideEffects) === null || _a === void 0 ? void 0 : _a.call(actionIn, {
|
|
341
|
-
s: s,
|
|
342
|
-
args: args,
|
|
343
|
-
p: p,
|
|
344
|
-
a: a,
|
|
345
|
-
err: err,
|
|
346
|
-
notifyWarning: notifyWarning,
|
|
347
|
-
ds: null,
|
|
348
|
-
derived: null,
|
|
349
|
-
state: s,
|
|
350
|
-
props: p,
|
|
351
|
-
actions: a,
|
|
352
|
-
error: err,
|
|
353
|
-
promiseId: (_b = actionIn.getPromiseId) === null || _b === void 0 ? void 0 : _b.call.apply(_b, __spreadArray([actionIn], args, false)),
|
|
354
|
-
});
|
|
355
|
-
},
|
|
356
|
-
getErrorMessage: function (err, args, p) {
|
|
357
|
-
var _a, _b;
|
|
358
|
-
return (_a = actionIn.getErrorMessage) === null || _a === void 0 ? void 0 : _a.call(actionIn, {
|
|
359
|
-
err: err,
|
|
360
|
-
p: p,
|
|
361
|
-
args: args,
|
|
362
|
-
ds: null,
|
|
363
|
-
derived: null,
|
|
364
|
-
state: null,
|
|
365
|
-
s: null,
|
|
366
|
-
error: err,
|
|
367
|
-
props: p,
|
|
368
|
-
promiseId: (_b = actionIn.getPromiseId) === null || _b === void 0 ? void 0 : _b.call.apply(_b, __spreadArray([actionIn], args, false)),
|
|
369
|
-
});
|
|
370
|
-
},
|
|
371
|
-
getSuccessMessage: function (res, args, p) {
|
|
372
|
-
var _a, _b;
|
|
373
|
-
return (_a = actionIn.getSuccessMessage) === null || _a === void 0 ? void 0 : _a.call(actionIn, {
|
|
374
|
-
res: res,
|
|
375
|
-
args: args,
|
|
376
|
-
p: p,
|
|
377
|
-
ds: null,
|
|
378
|
-
derived: null,
|
|
379
|
-
state: null,
|
|
380
|
-
s: null,
|
|
381
|
-
result: res,
|
|
382
|
-
props: p,
|
|
383
|
-
promiseId: (_b = actionIn.getPromiseId) === null || _b === void 0 ? void 0 : _b.call.apply(_b, __spreadArray([actionIn], args, false)),
|
|
384
|
-
});
|
|
385
|
-
},
|
|
386
|
-
};
|
|
387
|
-
return test(decoratedAction);
|
|
388
|
-
}
|
|
389
|
-
return Promise.reject(new Error('This action is not a synchronous action'));
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
export { isAdvancedSyncAction, isAsyncAction, isAsyncPromiseGetAction, isSyncAction, testAdvancedSyncAction, testAsyncAction, testSyncAction, testV6AdvancedSyncAction, testV6AsyncAction, testV6SyncAction };
|
|
393
|
-
//# sourceMappingURL=v5_test.js.map
|
package/es/v5_test.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"v5_test.js","sources":["../../node_modules/tslib/tslib.es6.js"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAiBA;AACO,IAAI,QAAQ,GAAG,WAAW;AACjC,IAAI,QAAQ,GAAG,MAAM,CAAC,MAAM,IAAI,SAAS,QAAQ,CAAC,CAAC,EAAE;AACrD,QAAQ,KAAK,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AAC7D,YAAY,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAC7B,YAAY,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACzF,SAAS;AACT,QAAQ,OAAO,CAAC,CAAC;AACjB,MAAK;AACL,IAAI,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AAC3C,EAAC;AA2HD;AACO,SAAS,aAAa,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;AAC9C,IAAI,IAAI,IAAI,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AACzF,QAAQ,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,IAAI,CAAC,EAAE;AAChC,YAAY,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACjE,YAAY,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AAC5B,SAAS;AACT,KAAK;AACL,IAAI,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/es/v5_types.d.ts
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
/*! *****************************************************************************
|
|
2
|
-
Copyright (c) GlobalSport SAS.
|
|
3
|
-
|
|
4
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
-
purpose with or without fee is hereby granted.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */
|
|
15
|
-
import { ConflictPolicy, DecoratedActions, NotifyFunc, PromiseResult } from './types';
|
|
16
|
-
export declare type PromiseProvider<S, F extends (...args: any[]) => any, A, P> = (args: Parameters<F>, state: S, props: P, actions: A, abortSignal: AbortSignal) => ReturnType<F> | null;
|
|
17
|
-
/**
|
|
18
|
-
* Simple form of a synchronous action.
|
|
19
|
-
*/
|
|
20
|
-
export declare type SynchAction<S, F extends (...args: any[]) => any, P> = (state: S, args: Parameters<F>, props: P) => S | null;
|
|
21
|
-
/**
|
|
22
|
-
* Advanced synchronous action.
|
|
23
|
-
* Allows to set advanced properties to a synchronous action.
|
|
24
|
-
*/
|
|
25
|
-
export declare type AdvancedSynchAction<S, F extends (...args: any[]) => any, A, P> = {
|
|
26
|
-
/**
|
|
27
|
-
* The action to execute.
|
|
28
|
-
*/
|
|
29
|
-
action: (state: S, args: Parameters<F>, props: P) => S | null;
|
|
30
|
-
/**
|
|
31
|
-
* Debounces the side effects if this parameter is defined.
|
|
32
|
-
*/
|
|
33
|
-
debounceSideEffectsTimeout?: number;
|
|
34
|
-
/**
|
|
35
|
-
* Debounces the action if this parameter is defined.
|
|
36
|
-
*/
|
|
37
|
-
debounceTimeout?: number;
|
|
38
|
-
/**
|
|
39
|
-
* Action to call when the action is done. Used to trigger other actions (even asynchronous),
|
|
40
|
-
*/
|
|
41
|
-
onActionDone?: (state: S, args: Parameters<F>, props: P, actions: A, notifyWarning: NotifyFunc) => void;
|
|
42
|
-
};
|
|
43
|
-
export declare type PromiseIdMap = {
|
|
44
|
-
[promiseId: string]: boolean;
|
|
45
|
-
};
|
|
46
|
-
export declare type InternalLoadingMap<A> = {
|
|
47
|
-
[name: string]: undefined | boolean | PromiseIdMap;
|
|
48
|
-
};
|
|
49
|
-
export declare type LoadingMap<A> = {
|
|
50
|
-
[P in keyof A]?: undefined | boolean;
|
|
51
|
-
};
|
|
52
|
-
export declare type LoadingMapParallelActions<A> = {
|
|
53
|
-
[P in keyof A]?: PromiseIdMap;
|
|
54
|
-
};
|
|
55
|
-
export declare type LoadingProps<A> = {
|
|
56
|
-
loading: boolean;
|
|
57
|
-
loadingMap: LoadingMap<A>;
|
|
58
|
-
loadingParallelMap: LoadingMapParallelActions<A>;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Try to abort an action, if the action is <code>abortable</code>.
|
|
62
|
-
* @param actionName The action name
|
|
63
|
-
* @param promiseId If the action conflict type is <code>ConflictType.PARALLEL</code>, the identifier of the promise.
|
|
64
|
-
* @returns <code>true</code> if the action is abortable and an action is ongoing, <code>false</code> otherwise.
|
|
65
|
-
*/
|
|
66
|
-
export declare type AbortActionCallback<A> = (actionName: keyof A, promiseId?: string) => boolean;
|
|
67
|
-
export declare type GetErrorMessage<F extends (...args: any[]) => any, P> = (e: any, args: Parameters<F>, props: P) => string;
|
|
68
|
-
export interface AsynchActionBase<S, F extends (...args: any[]) => any, A, P> {
|
|
69
|
-
/**
|
|
70
|
-
* This action can be aborted. An abortSignal will be injected to the <code>promise</code> / <code>promiseGet</code>.
|
|
71
|
-
*/
|
|
72
|
-
abortable?: boolean;
|
|
73
|
-
/**
|
|
74
|
-
* The success message to pass to the notifySuccess function passed as property to the StateDecorator.
|
|
75
|
-
*/
|
|
76
|
-
successMessage?: string;
|
|
77
|
-
/**
|
|
78
|
-
* A function that provides the success message to pass to the notifySuccess function passed as property to the StateDecorator.
|
|
79
|
-
*/
|
|
80
|
-
getSuccessMessage?: (result: PromiseResult<ReturnType<F>>, args: Parameters<F>, props: P) => string;
|
|
81
|
-
/**
|
|
82
|
-
* The error message to pass to the notifyError function passed as property to the StateDecorator.
|
|
83
|
-
*/
|
|
84
|
-
errorMessage?: string;
|
|
85
|
-
/**
|
|
86
|
-
* A function that provides the error message to pass to the notifyError function passed as property to the StateDecorator.
|
|
87
|
-
*/
|
|
88
|
-
getErrorMessage?: GetErrorMessage<F, P>;
|
|
89
|
-
/**
|
|
90
|
-
* If set, called with the result of the promise to update the current state.
|
|
91
|
-
*/
|
|
92
|
-
reducer?: (state: S, result: PromiseResult<ReturnType<F>>, args: Parameters<F>, props: P) => S | null;
|
|
93
|
-
/**
|
|
94
|
-
* If set, called with the error of the promise to update the current state.
|
|
95
|
-
*/
|
|
96
|
-
errorReducer?: (state: S, error: any, args: Parameters<F>, props: P) => S | null;
|
|
97
|
-
/**
|
|
98
|
-
* Whether reject the promise instead of handling it.
|
|
99
|
-
*/
|
|
100
|
-
rejectPromiseOnError?: boolean;
|
|
101
|
-
/**
|
|
102
|
-
* Handle side effects when the request succeeded.
|
|
103
|
-
* @param result The result of the request
|
|
104
|
-
* @param newData The data after the reducer is applied
|
|
105
|
-
* @param args The argument during the call of the request function
|
|
106
|
-
* @param props The props passed to the state decorator
|
|
107
|
-
* @param actions The actions available
|
|
108
|
-
* @param notifyWarning If specified, a notify function to indicate that the action is a semi success (use successMessage / getSuccessMessage otherwise).
|
|
109
|
-
*/
|
|
110
|
-
onDone?: (state: S, result: PromiseResult<ReturnType<F>>, args: Parameters<F>, props: P, actions: A, notifyWarning: NotifyFunc) => void;
|
|
111
|
-
/**
|
|
112
|
-
* Handle side effects when the request failed.
|
|
113
|
-
* @param error The error of the request
|
|
114
|
-
* @param args The argument during the call of the request function
|
|
115
|
-
* @param props The props passed to the state decorator
|
|
116
|
-
* @param actions The actions available
|
|
117
|
-
* @param notifyWarning If specified, a notify function to indicate that the action is a semi failure (use errorMessage / getErrorMessage otherwise).
|
|
118
|
-
*/
|
|
119
|
-
onFail?: (state: S, error: Error, args: Parameters<F>, props: P, actions: A, notifyWarning: NotifyFunc) => void;
|
|
120
|
-
/**
|
|
121
|
-
* Retrieve the state to set as current data before the promise is resolved.
|
|
122
|
-
* If the there's no reducer, this data will be used after the promise is done.
|
|
123
|
-
*/
|
|
124
|
-
preReducer?: (state: S, args: Parameters<F>, props: P) => S | null;
|
|
125
|
-
/**
|
|
126
|
-
* Retrieve the state to set as current data before the promise is resolved.
|
|
127
|
-
* If the there's no reducer, this data will be used after the promise is done.
|
|
128
|
-
*/
|
|
129
|
-
optimisticReducer?: (state: S, args: Parameters<F>, props: P) => S | null;
|
|
130
|
-
/**
|
|
131
|
-
* Policy to apply when a call to an asynchronous action is done but a previous call is still not resolved.
|
|
132
|
-
*/
|
|
133
|
-
conflictPolicy?: ConflictPolicy;
|
|
134
|
-
/**
|
|
135
|
-
* Get an identifier for an action call. Used only when conflictPolicy is ConflictPolicy.PARALLEL.
|
|
136
|
-
* This information will be available in loadingMap. loadingMap[actionName] will be an array of promise identifiers.
|
|
137
|
-
*/
|
|
138
|
-
getPromiseId?: (...args: Parameters<F>) => string;
|
|
139
|
-
/**
|
|
140
|
-
* Number of retries in case of error (failed to fetch).
|
|
141
|
-
* Do not use this if you are creating objects...
|
|
142
|
-
* Default value is 0 (no retry).
|
|
143
|
-
*/
|
|
144
|
-
retryCount?: number;
|
|
145
|
-
/**
|
|
146
|
-
* Seed of delay between each retry in milliseconds.
|
|
147
|
-
* The applied delay is retryDelaySeed * retry count.
|
|
148
|
-
* Default value is 1000 (1 second).
|
|
149
|
-
*/
|
|
150
|
-
retryDelaySeed?: number;
|
|
151
|
-
/**
|
|
152
|
-
* Function to test if the error will trigger an action retry or will fail directly.
|
|
153
|
-
*/
|
|
154
|
-
isTriggerRetryError?: (e: Error) => boolean;
|
|
155
|
-
}
|
|
156
|
-
export interface AsynchActionPromise<S, F extends (...args: any[]) => any, A, P> extends AsynchActionBase<S, F, A, P> {
|
|
157
|
-
/**
|
|
158
|
-
* The request, returns a promise
|
|
159
|
-
*/
|
|
160
|
-
promise: PromiseProvider<S, F, A, P>;
|
|
161
|
-
}
|
|
162
|
-
export interface AsynchActionPromiseGet<S, F extends (...args: any[]) => any, A, P> extends AsynchActionBase<S, F, A, P> {
|
|
163
|
-
/**
|
|
164
|
-
* The request, returns a promise that is a GET request.
|
|
165
|
-
* A shortcut to set:
|
|
166
|
-
* - retryCount: 3
|
|
167
|
-
* - conflictPolicy: ConflictPolicy.REUSE
|
|
168
|
-
*/
|
|
169
|
-
promiseGet: PromiseProvider<S, F, A, P>;
|
|
170
|
-
}
|
|
171
|
-
export declare type AsynchAction<S, F extends (...args: any[]) => any, A, P> = AsynchActionPromise<S, F, A, P> | AsynchActionPromiseGet<S, F, A, P>;
|
|
172
|
-
export declare type StateDecoratorAction<S, F extends (...args: any[]) => any, A, P> = AsynchAction<S, F, A, P> | SynchAction<S, F, P> | AdvancedSynchAction<S, F, A, P>;
|
|
173
|
-
/**
|
|
174
|
-
* S: The type of the state
|
|
175
|
-
* A: The type of the actions to pass to the children (used to check keys only).
|
|
176
|
-
*/
|
|
177
|
-
export declare type StateDecoratorActions<S, A extends DecoratedActions, P = {}> = {
|
|
178
|
-
[Prop in keyof A]: StateDecoratorAction<S, A[Prop], A, P>;
|
|
179
|
-
};
|
|
180
|
-
declare type OnPropsChangeReducer<S, P> = (s: S, newProps: P, updatedIndices: number[]) => S;
|
|
181
|
-
export declare type StateDecoratorOptions<S, A, P = {}> = {
|
|
182
|
-
/**
|
|
183
|
-
* The state decorator name. Use in debug traces to identify the useStateDecorator instance.
|
|
184
|
-
*/
|
|
185
|
-
name?: string;
|
|
186
|
-
/**
|
|
187
|
-
* Show logs in the console in development mode.
|
|
188
|
-
*/
|
|
189
|
-
logEnabled?: boolean;
|
|
190
|
-
/**
|
|
191
|
-
* List of action names that are marked as loading at initial time.
|
|
192
|
-
* As a render is done before first actions can be trigerred, some actions can be marked as loading at
|
|
193
|
-
* initial time.
|
|
194
|
-
*/
|
|
195
|
-
initialActionsMarkedLoading?: (keyof A)[];
|
|
196
|
-
/**
|
|
197
|
-
* Get a list of values that will be use as reference values.
|
|
198
|
-
* If they are different (shallow compare), onPropsChangeReducer then onPropsChange will be called.
|
|
199
|
-
*/
|
|
200
|
-
getPropsRefValues?: (props: P) => any[];
|
|
201
|
-
/**
|
|
202
|
-
* Triggered when values of reference from props have changed. Allow to call actions after a prop change.
|
|
203
|
-
*/
|
|
204
|
-
onPropsChange?: (s: S, newProps: any, actions: A, updatedIndices: number[]) => void;
|
|
205
|
-
/**
|
|
206
|
-
* Triggered when values of reference from props have changed. Allow to update state after a prop change.
|
|
207
|
-
* <b>null</b> means no change.
|
|
208
|
-
*/
|
|
209
|
-
onPropsChangeReducer?: OnPropsChangeReducer<S, P>;
|
|
210
|
-
/**
|
|
211
|
-
* The callback function called if an asynchronous function succeeded and a success messsage is defined.
|
|
212
|
-
*/
|
|
213
|
-
notifySuccess?: NotifyFunc;
|
|
214
|
-
/**
|
|
215
|
-
* The callback function called if an asynchronous function fails and an error messsage is defined.
|
|
216
|
-
*/
|
|
217
|
-
notifyError?: NotifyFunc;
|
|
218
|
-
/**
|
|
219
|
-
* The callback function injected in onDone and onFail of asynchronous functions to notify a semi success / failed request.
|
|
220
|
-
*/
|
|
221
|
-
notifyWarning?: NotifyFunc;
|
|
222
|
-
/**
|
|
223
|
-
* Initial actions. They are executed outside of a side effect to trigger asynchronous actions.
|
|
224
|
-
*/
|
|
225
|
-
onMount?: (actions: A, props: P, state: S) => void;
|
|
226
|
-
};
|
|
227
|
-
export {};
|
package/es/v6.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { GlobalConfig, ParallelActionError, EffectError } from './impl';
|
|
2
|
-
import { DecoratedActions, StoreActions, AsyncAction, SyncAction, SimpleSyncAction, LoadingMap, ErrorMap, LoadingParallelMap, ErrorParallelMap, StoreOptions, AsyncActionPromise, InvocationContext, GetPromiseInvocationContext, EffectsInvocationContext, InvocationContextActions, WarningNotifyFunc, ErrorEffectsInvocationContext, OnMountInvocationContext, ContextBase, OnPropsChangeEffectsContext, ContextState, ConflictPolicy, Middleware, AbortActionCallback, MiddlewareFactory, LoadingProps, ErrorProps, LoadingMapProps, StoreConfig } from './types';
|
|
3
|
-
import { setGlobalConfig, IsLoadingFunc, StoreApi, StateListenerContext } from './index';
|
|
4
|
-
export { StateListenerContext, StoreApi, EffectError, DecoratedActions, StoreActions, LoadingMap, ErrorMap, LoadingParallelMap, ErrorParallelMap, ParallelActionError, StoreOptions, AsyncActionPromise as AsynchActionPromise, InvocationContext, GetPromiseInvocationContext, EffectsInvocationContext, InvocationContextActions, WarningNotifyFunc, ErrorEffectsInvocationContext, OnMountInvocationContext, ContextBase, OnPropsChangeEffectsContext, SyncAction, AsyncAction, SimpleSyncAction, ContextState, ConflictPolicy, GlobalConfig, Middleware, setGlobalConfig, LoadingProps, AbortActionCallback, ErrorProps, LoadingMapProps, StoreConfig, IsLoadingFunc, };
|
|
5
|
-
/**
|
|
6
|
-
* Creates and manages a local store.
|
|
7
|
-
* The component will be refreshed for every change in the store.
|
|
8
|
-
* Store will NOT be destroyed when component is unmouted.
|
|
9
|
-
*
|
|
10
|
-
* @param getInitialState Function to compute initial state from props.
|
|
11
|
-
* @param actionImpl Actions implementation.
|
|
12
|
-
* @param props Owner component props to update state or react on prop changes
|
|
13
|
-
* @param options The store options.
|
|
14
|
-
* @param refreshOnUpdate Whether refresh the component if store state changes.
|
|
15
|
-
* @returns The state, actions and isLoading function.
|
|
16
|
-
*/
|
|
17
|
-
export default function useLocalStoreV6<S, A extends DecoratedActions, P, DS = {}>(getInitialState: (p: P) => S, actionImpl: StoreActions<S, A, P, DS>, props?: P, options?: StoreOptions<S, A, P, DS>, middlewares?: MiddlewareFactory<S, A, P>[], refreshOnUpdate?: boolean): StoreApi<S, A, P, DS>;
|