state-decorator 7.2.1 → 7.3.0-optim.1
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/development.d.ts +10 -10
- package/es/development.d.ts +10 -10
- package/es/graph.d.ts +8 -8
- package/es/helpers.d.ts +67 -67
- package/es/impl.d.ts +209 -199
- package/es/impl.js +1 -1
- package/es/index.d.ts +169 -169
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/middlewares.d.ts +3 -3
- package/es/shallow.d.ts +1 -1
- package/es/test.d.ts +122 -122
- package/es/test.js +1 -1
- package/es/test.js.map +1 -1
- package/es/types.d.ts +386 -386
- package/es/v5.d.ts +45 -45
- package/es/v5_test.d.ts +57 -57
- package/es/v5_types.d.ts +213 -213
- package/es/v6.d.ts +21 -21
- package/graph.d.ts +8 -8
- package/helpers.d.ts +67 -67
- package/impl.d.ts +209 -199
- package/impl.js +1 -1
- package/index.d.ts +169 -169
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/middlewares.d.ts +3 -3
- package/package.json +1 -1
- package/shallow.d.ts +1 -1
- package/test.d.ts +122 -122
- package/test.js +1 -1
- package/test.js.map +1 -1
- package/types.d.ts +386 -386
- package/v5.d.ts +45 -45
- package/v5_test.d.ts +57 -57
- package/v5_types.d.ts +213 -213
- package/v6.d.ts +21 -21
package/development.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { DecoratedActions, MiddlewareFactory } from './types';
|
|
2
|
-
export type Logger = {
|
|
3
|
-
log: (...args: any[]) => void;
|
|
4
|
-
group: (...args: any[]) => void;
|
|
5
|
-
groupCollapsed: (...args: any[]) => void;
|
|
6
|
-
groupEnd: (...args: any[]) => void;
|
|
7
|
-
};
|
|
8
|
-
export declare let logEffects: <S, A extends DecoratedActions, P>(log?: (...msg: any[]) => void) => MiddlewareFactory<S, A, P>;
|
|
9
|
-
export declare let logDetailedEffects: <S, A extends DecoratedActions, P>(logger?: Logger) => MiddlewareFactory<S, A, P>;
|
|
10
|
-
export declare let devtools: <S, A extends DecoratedActions, P>() => MiddlewareFactory<S, A, P>;
|
|
1
|
+
import type { DecoratedActions, MiddlewareFactory } from './types';
|
|
2
|
+
export type Logger = {
|
|
3
|
+
log: (...args: any[]) => void;
|
|
4
|
+
group: (...args: any[]) => void;
|
|
5
|
+
groupCollapsed: (...args: any[]) => void;
|
|
6
|
+
groupEnd: (...args: any[]) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare let logEffects: <S, A extends DecoratedActions, P>(log?: (...msg: any[]) => void) => MiddlewareFactory<S, A, P>;
|
|
9
|
+
export declare let logDetailedEffects: <S, A extends DecoratedActions, P>(logger?: Logger) => MiddlewareFactory<S, A, P>;
|
|
10
|
+
export declare let devtools: <S, A extends DecoratedActions, P>() => MiddlewareFactory<S, A, P>;
|
package/es/development.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { DecoratedActions, MiddlewareFactory } from './types';
|
|
2
|
-
export type Logger = {
|
|
3
|
-
log: (...args: any[]) => void;
|
|
4
|
-
group: (...args: any[]) => void;
|
|
5
|
-
groupCollapsed: (...args: any[]) => void;
|
|
6
|
-
groupEnd: (...args: any[]) => void;
|
|
7
|
-
};
|
|
8
|
-
export declare let logEffects: <S, A extends DecoratedActions, P>(log?: (...msg: any[]) => void) => MiddlewareFactory<S, A, P>;
|
|
9
|
-
export declare let logDetailedEffects: <S, A extends DecoratedActions, P>(logger?: Logger) => MiddlewareFactory<S, A, P>;
|
|
10
|
-
export declare let devtools: <S, A extends DecoratedActions, P>() => MiddlewareFactory<S, A, P>;
|
|
1
|
+
import type { DecoratedActions, MiddlewareFactory } from './types';
|
|
2
|
+
export type Logger = {
|
|
3
|
+
log: (...args: any[]) => void;
|
|
4
|
+
group: (...args: any[]) => void;
|
|
5
|
+
groupCollapsed: (...args: any[]) => void;
|
|
6
|
+
groupEnd: (...args: any[]) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare let logEffects: <S, A extends DecoratedActions, P>(log?: (...msg: any[]) => void) => MiddlewareFactory<S, A, P>;
|
|
9
|
+
export declare let logDetailedEffects: <S, A extends DecoratedActions, P>(logger?: Logger) => MiddlewareFactory<S, A, P>;
|
|
10
|
+
export declare let devtools: <S, A extends DecoratedActions, P>() => MiddlewareFactory<S, A, P>;
|
package/es/graph.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export default class Graph {
|
|
2
|
-
private keys;
|
|
3
|
-
private adj;
|
|
4
|
-
constructor(keys: string[]);
|
|
5
|
-
private isCyclicUtil;
|
|
6
|
-
setEdges(sou: string, dest: string[]): void;
|
|
7
|
-
isCyclic(): boolean;
|
|
8
|
-
}
|
|
1
|
+
export default class Graph {
|
|
2
|
+
private keys;
|
|
3
|
+
private adj;
|
|
4
|
+
constructor(keys: string[]);
|
|
5
|
+
private isCyclicUtil;
|
|
6
|
+
setEdges(sou: string, dest: string[]): void;
|
|
7
|
+
isCyclic(): boolean;
|
|
8
|
+
}
|
package/es/helpers.d.ts
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Effect function that sets the first action argument to the specified prop.
|
|
3
|
-
* if dirtyProp is set
|
|
4
|
-
*/
|
|
5
|
-
export declare function setArgIn<S, K extends keyof S, K2 extends keyof S>(propName: K, dirtyProp?: K2): (ctx: {
|
|
6
|
-
s: S;
|
|
7
|
-
args: [S[K]];
|
|
8
|
-
}) => Partial<S>;
|
|
9
|
-
/**
|
|
10
|
-
* Effect function that sets <code>true</code> in the specified prop.
|
|
11
|
-
*/
|
|
12
|
-
export declare function setTrueIn<S, K extends keyof S, K2 extends keyof S>(propName: K, dirtyProp?: K2): (ctx: {
|
|
13
|
-
s: S;
|
|
14
|
-
}) => Partial<S>;
|
|
15
|
-
/**
|
|
16
|
-
* Effect function that sets <code>false</code> in the specified prop.
|
|
17
|
-
*/
|
|
18
|
-
export declare function setFalseIn<S, K extends keyof S, K2 extends keyof S>(propName: K, dirtyProp?: K2): (ctx: {
|
|
19
|
-
s: S;
|
|
20
|
-
}) => Partial<S>;
|
|
21
|
-
/**
|
|
22
|
-
* Effect function that sets toggles the boolean value of the specified prop.
|
|
23
|
-
*/
|
|
24
|
-
export declare function toggleProp<S, K extends keyof S, K2 extends keyof S>(propName: K, dirtyProp?: K2): (ctx: {
|
|
25
|
-
s: S;
|
|
26
|
-
}) => Partial<S>;
|
|
27
|
-
/**
|
|
28
|
-
* Effect function that sets the update the specifed prop as an array using first action argument as index
|
|
29
|
-
* and second as value to set.
|
|
30
|
-
*/
|
|
31
|
-
export declare function setArgsInMap<S, K extends keyof S, K2 extends keyof S, T>(propName: K, dirtyProp?: K2): (ctx: {
|
|
32
|
-
s: S;
|
|
33
|
-
args: [string, T];
|
|
34
|
-
}) => Partial<S>;
|
|
35
|
-
/**
|
|
36
|
-
* Effect function that sets the update the specifed prop as an array using first action argument as index
|
|
37
|
-
* and second as value to set.
|
|
38
|
-
*/
|
|
39
|
-
export declare function setArgsInArray<S, K extends keyof S, K2 extends keyof S, T>(propName: K, dirtyProp?: K2): (ctx: {
|
|
40
|
-
s: S;
|
|
41
|
-
args: [number, T];
|
|
42
|
-
}) => Partial<S>;
|
|
43
|
-
/**
|
|
44
|
-
* Effect function that sets the asynchronous action result to the specified prop.
|
|
45
|
-
*/
|
|
46
|
-
export declare function setResIn<S, K extends keyof S, K2 extends keyof S>(propName: K, dirtyProp?: K2): (ctx: {
|
|
47
|
-
s: S;
|
|
48
|
-
res: S[K];
|
|
49
|
-
}) => Partial<S>;
|
|
50
|
-
/**
|
|
51
|
-
* Effect function that sets the update the specifed prop as an array using first action argument as index
|
|
52
|
-
* and second as value to set.
|
|
53
|
-
*/
|
|
54
|
-
export declare function setResInArray<S, K extends keyof S, K2 extends keyof S, T>(propName: K, dirtyProp?: K2): (ctx: {
|
|
55
|
-
s: S;
|
|
56
|
-
args: [number];
|
|
57
|
-
res: T;
|
|
58
|
-
}) => Partial<S>;
|
|
59
|
-
/**
|
|
60
|
-
* Effect function that sets the update the specifed prop as an array using first action argument as index
|
|
61
|
-
* and second as value to set.
|
|
62
|
-
*/
|
|
63
|
-
export declare function setResInMap<S, K extends keyof S, K2 extends keyof S, T>(propName: K, dirtyProp?: K2): (ctx: {
|
|
64
|
-
s: S;
|
|
65
|
-
args: [string];
|
|
66
|
-
res: T;
|
|
67
|
-
}) => Partial<S>;
|
|
1
|
+
/**
|
|
2
|
+
* Effect function that sets the first action argument to the specified prop.
|
|
3
|
+
* if dirtyProp is set
|
|
4
|
+
*/
|
|
5
|
+
export declare function setArgIn<S, K extends keyof S, K2 extends keyof S>(propName: K, dirtyProp?: K2): (ctx: {
|
|
6
|
+
s: S;
|
|
7
|
+
args: [S[K]];
|
|
8
|
+
}) => Partial<S>;
|
|
9
|
+
/**
|
|
10
|
+
* Effect function that sets <code>true</code> in the specified prop.
|
|
11
|
+
*/
|
|
12
|
+
export declare function setTrueIn<S, K extends keyof S, K2 extends keyof S>(propName: K, dirtyProp?: K2): (ctx: {
|
|
13
|
+
s: S;
|
|
14
|
+
}) => Partial<S>;
|
|
15
|
+
/**
|
|
16
|
+
* Effect function that sets <code>false</code> in the specified prop.
|
|
17
|
+
*/
|
|
18
|
+
export declare function setFalseIn<S, K extends keyof S, K2 extends keyof S>(propName: K, dirtyProp?: K2): (ctx: {
|
|
19
|
+
s: S;
|
|
20
|
+
}) => Partial<S>;
|
|
21
|
+
/**
|
|
22
|
+
* Effect function that sets toggles the boolean value of the specified prop.
|
|
23
|
+
*/
|
|
24
|
+
export declare function toggleProp<S, K extends keyof S, K2 extends keyof S>(propName: K, dirtyProp?: K2): (ctx: {
|
|
25
|
+
s: S;
|
|
26
|
+
}) => Partial<S>;
|
|
27
|
+
/**
|
|
28
|
+
* Effect function that sets the update the specifed prop as an array using first action argument as index
|
|
29
|
+
* and second as value to set.
|
|
30
|
+
*/
|
|
31
|
+
export declare function setArgsInMap<S, K extends keyof S, K2 extends keyof S, T>(propName: K, dirtyProp?: K2): (ctx: {
|
|
32
|
+
s: S;
|
|
33
|
+
args: [string, T];
|
|
34
|
+
}) => Partial<S>;
|
|
35
|
+
/**
|
|
36
|
+
* Effect function that sets the update the specifed prop as an array using first action argument as index
|
|
37
|
+
* and second as value to set.
|
|
38
|
+
*/
|
|
39
|
+
export declare function setArgsInArray<S, K extends keyof S, K2 extends keyof S, T>(propName: K, dirtyProp?: K2): (ctx: {
|
|
40
|
+
s: S;
|
|
41
|
+
args: [number, T];
|
|
42
|
+
}) => Partial<S>;
|
|
43
|
+
/**
|
|
44
|
+
* Effect function that sets the asynchronous action result to the specified prop.
|
|
45
|
+
*/
|
|
46
|
+
export declare function setResIn<S, K extends keyof S, K2 extends keyof S>(propName: K, dirtyProp?: K2): (ctx: {
|
|
47
|
+
s: S;
|
|
48
|
+
res: S[K];
|
|
49
|
+
}) => Partial<S>;
|
|
50
|
+
/**
|
|
51
|
+
* Effect function that sets the update the specifed prop as an array using first action argument as index
|
|
52
|
+
* and second as value to set.
|
|
53
|
+
*/
|
|
54
|
+
export declare function setResInArray<S, K extends keyof S, K2 extends keyof S, T>(propName: K, dirtyProp?: K2): (ctx: {
|
|
55
|
+
s: S;
|
|
56
|
+
args: [number];
|
|
57
|
+
res: T;
|
|
58
|
+
}) => Partial<S>;
|
|
59
|
+
/**
|
|
60
|
+
* Effect function that sets the update the specifed prop as an array using first action argument as index
|
|
61
|
+
* and second as value to set.
|
|
62
|
+
*/
|
|
63
|
+
export declare function setResInMap<S, K extends keyof S, K2 extends keyof S, T>(propName: K, dirtyProp?: K2): (ctx: {
|
|
64
|
+
s: S;
|
|
65
|
+
args: [string];
|
|
66
|
+
res: T;
|
|
67
|
+
}) => Partial<S>;
|
package/es/impl.d.ts
CHANGED
|
@@ -1,199 +1,209 @@
|
|
|
1
|
-
import { AsyncAction, SimpleSyncAction, SyncAction, StoreAction, AsyncActionPromise, AsyncActionPromiseGet, PromiseProvider, DecoratedActions, InternalLoadingMap, StoreOptions, InvocationContextActions, OnMountInvocationContext, OnPropsChangeEffectsContext, ContextState, Middleware, MiddlewareFactory, ContextWithDerived, PromiseIdErrorMap, ErrorMap, ErrorParallelMap, OnUnMountInvocationContext, AbortedActions, ClearErrorFunc, StoreConfig, StoreConfigFunc } from './types';
|
|
2
|
-
export type SetStateFunc<S, A> = (newState: S, newLoadingMap: InternalLoadingMap<A>, actionName: keyof A | 'onPropsChange', actionType: 'preEffects' | 'effects' | 'errorEffects' | null, // FIXME
|
|
3
|
-
isAsync: boolean, actionCtx: any, propsChanged: boolean, isInit?: boolean) => void;
|
|
4
|
-
/** @internal */
|
|
5
|
-
export type PromiseMap<A> = {
|
|
6
|
-
[name in keyof A]?: {
|
|
7
|
-
[promiseId: string]: {
|
|
8
|
-
promise: Promise<any>;
|
|
9
|
-
refArgs: any[];
|
|
10
|
-
abortController: AbortController;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
/** @internal */
|
|
15
|
-
export type FutureActions = {
|
|
16
|
-
args: any[];
|
|
17
|
-
resolve: (...args: any[]) => void;
|
|
18
|
-
reject: (...args: any[]) => void;
|
|
19
|
-
timestamp?: number;
|
|
20
|
-
};
|
|
21
|
-
/** @internal */
|
|
22
|
-
export type ConflictActionsMap<A> = {
|
|
23
|
-
[name in keyof A]?: FutureActions[];
|
|
24
|
-
};
|
|
25
|
-
/** @internal */
|
|
26
|
-
export type AsyncActionExecContext<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P> = {
|
|
27
|
-
actionName: keyof A;
|
|
28
|
-
action: AsyncActionPromise<S, F, A, P, DS>;
|
|
29
|
-
stateRef: Ref<S>;
|
|
30
|
-
derivedStateRef: Ref<DerivedState<DS>>;
|
|
31
|
-
propsRef: Ref<P>;
|
|
32
|
-
loadingParallelMapRef: Ref<InternalLoadingMap<A>>;
|
|
33
|
-
errorMapRef: Ref<ErrorParallelMap<A>>;
|
|
34
|
-
promisesRef: Ref<PromiseMap<A>>;
|
|
35
|
-
conflictActionsRef: Ref<ConflictActionsMap<A>>;
|
|
36
|
-
actionsRef: Ref<A>;
|
|
37
|
-
initializedRef: Ref<boolean>;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
export type
|
|
48
|
-
export type
|
|
49
|
-
export type
|
|
50
|
-
export type
|
|
51
|
-
type
|
|
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
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
*
|
|
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
|
-
export declare function
|
|
145
|
-
/**
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
export declare function
|
|
149
|
-
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
export
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
export
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
/** @internal */
|
|
172
|
-
export declare function
|
|
173
|
-
/** @internal */
|
|
174
|
-
export declare function
|
|
175
|
-
/** @internal */
|
|
176
|
-
export declare function
|
|
177
|
-
/** @internal */
|
|
178
|
-
export declare function
|
|
179
|
-
/** @internal */
|
|
180
|
-
export declare function
|
|
181
|
-
/** @internal */
|
|
182
|
-
export declare function
|
|
183
|
-
/** @internal */
|
|
184
|
-
export declare function
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
export declare
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
export
|
|
1
|
+
import { AsyncAction, SimpleSyncAction, SyncAction, StoreAction, AsyncActionPromise, AsyncActionPromiseGet, PromiseProvider, DecoratedActions, InternalLoadingMap, StoreOptions, InvocationContextActions, OnMountInvocationContext, OnPropsChangeEffectsContext, ContextState, Middleware, MiddlewareFactory, ContextWithDerived, PromiseIdErrorMap, ErrorMap, ErrorParallelMap, OnUnMountInvocationContext, AbortedActions, ClearErrorFunc, StoreConfig, StoreConfigFunc } from './types';
|
|
2
|
+
export type SetStateFunc<S, A> = (newState: S, newLoadingMap: InternalLoadingMap<A>, actionName: keyof A | 'onPropsChange', actionType: 'preEffects' | 'effects' | 'errorEffects' | null, // FIXME
|
|
3
|
+
isAsync: boolean, actionCtx: any, propsChanged: boolean, isInit?: boolean, disableNotify?: boolean) => () => void;
|
|
4
|
+
/** @internal */
|
|
5
|
+
export type PromiseMap<A> = {
|
|
6
|
+
[name in keyof A]?: {
|
|
7
|
+
[promiseId: string]: {
|
|
8
|
+
promise: Promise<any>;
|
|
9
|
+
refArgs: any[];
|
|
10
|
+
abortController: AbortController;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
/** @internal */
|
|
15
|
+
export type FutureActions = {
|
|
16
|
+
args: any[];
|
|
17
|
+
resolve: (...args: any[]) => void;
|
|
18
|
+
reject: (...args: any[]) => void;
|
|
19
|
+
timestamp?: number;
|
|
20
|
+
};
|
|
21
|
+
/** @internal */
|
|
22
|
+
export type ConflictActionsMap<A> = {
|
|
23
|
+
[name in keyof A]?: FutureActions[];
|
|
24
|
+
};
|
|
25
|
+
/** @internal */
|
|
26
|
+
export type AsyncActionExecContext<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P> = {
|
|
27
|
+
actionName: keyof A;
|
|
28
|
+
action: AsyncActionPromise<S, F, A, P, DS>;
|
|
29
|
+
stateRef: Ref<S>;
|
|
30
|
+
derivedStateRef: Ref<DerivedState<DS>>;
|
|
31
|
+
propsRef: Ref<P>;
|
|
32
|
+
loadingParallelMapRef: Ref<InternalLoadingMap<A>>;
|
|
33
|
+
errorMapRef: Ref<ErrorParallelMap<A>>;
|
|
34
|
+
promisesRef: Ref<PromiseMap<A>>;
|
|
35
|
+
conflictActionsRef: Ref<ConflictActionsMap<A>>;
|
|
36
|
+
actionsRef: Ref<A>;
|
|
37
|
+
initializedRef: Ref<boolean>;
|
|
38
|
+
stateFlagRef: Ref<boolean>;
|
|
39
|
+
options: StoreOptions<S, A, P, any>;
|
|
40
|
+
setState: SetStateFunc<S, A>;
|
|
41
|
+
clearError: ClearErrorFunc<A>;
|
|
42
|
+
};
|
|
43
|
+
/** @internal */
|
|
44
|
+
export type TimeoutMap<A> = {
|
|
45
|
+
[name in keyof A]?: any;
|
|
46
|
+
};
|
|
47
|
+
export type NotifyFunc = (msg: string) => void;
|
|
48
|
+
export type CloneFunction = <C>(obj: C) => C;
|
|
49
|
+
export type ComparatorFunction = <C>(obj1: C, Obj2: C) => boolean;
|
|
50
|
+
export type RetryOnErrorFunction = (error: any) => boolean;
|
|
51
|
+
export type AsyncErrorHandler = (error: any, isHandled: boolean, state: any, props: any, actionName: string, args: any[]) => void;
|
|
52
|
+
type DerivedStateMap<DS> = {
|
|
53
|
+
[name in keyof DS]?: any[];
|
|
54
|
+
};
|
|
55
|
+
/** @internal */
|
|
56
|
+
export type DerivedState<DS> = {
|
|
57
|
+
state: DS;
|
|
58
|
+
deps: DerivedStateMap<DS>;
|
|
59
|
+
};
|
|
60
|
+
export declare class EffectError extends Error {
|
|
61
|
+
/**
|
|
62
|
+
* The wrapped error
|
|
63
|
+
*/
|
|
64
|
+
source: any;
|
|
65
|
+
/**
|
|
66
|
+
* If effects error occurred while processed an error, the initial error.
|
|
67
|
+
*/
|
|
68
|
+
initialError: Error;
|
|
69
|
+
constructor(source: any, initialError?: Error);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Global configuration, shared with all stores.
|
|
73
|
+
*/
|
|
74
|
+
export type GlobalConfig = {
|
|
75
|
+
/**
|
|
76
|
+
* Clone function.
|
|
77
|
+
* Used to clone state and props when managing optimistic reducer and conflicting actions.
|
|
78
|
+
* Default implementation is a very basic algorithm using JSON.stringify. To clone complex stats,
|
|
79
|
+
* use a custom implementation like lodash/cloneDeep.
|
|
80
|
+
* @default JSON.stringify
|
|
81
|
+
*/
|
|
82
|
+
clone: CloneFunction;
|
|
83
|
+
/**
|
|
84
|
+
* Compare to objets and returns if they are equal.
|
|
85
|
+
* Used to comparent previous and current state slice.
|
|
86
|
+
* @default shallow
|
|
87
|
+
*/
|
|
88
|
+
comparator: ComparatorFunction;
|
|
89
|
+
/**
|
|
90
|
+
* Global callback function to handle asychronous actions rejected promise.
|
|
91
|
+
*/
|
|
92
|
+
asyncErrorHandler: AsyncErrorHandler;
|
|
93
|
+
/**
|
|
94
|
+
* Tests if the error will trigger a retry of the action or will fail directly.
|
|
95
|
+
* Default implementation is returning true for TypeError instances only.
|
|
96
|
+
* @see AsynchActionBase#retryCount
|
|
97
|
+
*/
|
|
98
|
+
retryOnErrorFunction: RetryOnErrorFunction;
|
|
99
|
+
/**
|
|
100
|
+
* First retry timeout. Every retry will wait x
|
|
101
|
+
*/
|
|
102
|
+
autoRetryTimeout: number;
|
|
103
|
+
/**
|
|
104
|
+
* Number of retries in case of error (failed to fetch).
|
|
105
|
+
* If <code>0</code>, retry is globally disabled.
|
|
106
|
+
*/
|
|
107
|
+
autoRetryCount: number;
|
|
108
|
+
/**
|
|
109
|
+
* Global notification function that will called when an asynchronous action succeeded,
|
|
110
|
+
* if and only if, an error message is specified for this action using
|
|
111
|
+
* <code>getErrorMessage</code>.
|
|
112
|
+
* If another function is set in the options, the function from the options will be used.
|
|
113
|
+
*/
|
|
114
|
+
notifySuccess: NotifyFunc;
|
|
115
|
+
/**
|
|
116
|
+
* Global notification function that will called when an asynchronous action fails,
|
|
117
|
+
* if and only if, an error message is specified for this action using
|
|
118
|
+
* <code>getErrorMessage</code>.
|
|
119
|
+
* If another function is set in the options, the function from the options will be used.
|
|
120
|
+
*/
|
|
121
|
+
notifyError: NotifyFunc;
|
|
122
|
+
/**
|
|
123
|
+
* Global notification function that will injected in onDone and onFail of an asynchronous actions and onActionDone of a synchronous function,
|
|
124
|
+
* If another function is set in the options, the function from the options will be used.
|
|
125
|
+
*/
|
|
126
|
+
notifyWarning: NotifyFunc;
|
|
127
|
+
/**
|
|
128
|
+
* A default error message provider.
|
|
129
|
+
* Used to return generic messages on generic HTTP errors
|
|
130
|
+
*/
|
|
131
|
+
getErrorMessage: (error: Error) => string;
|
|
132
|
+
/**
|
|
133
|
+
* Default middlewares. Store middleware array will be concatenated with this one.
|
|
134
|
+
* By default contains only the optimistic middleware.
|
|
135
|
+
*/
|
|
136
|
+
defaultMiddlewares: MiddlewareFactory<any, any, any>[];
|
|
137
|
+
};
|
|
138
|
+
/** @internal */
|
|
139
|
+
export declare const globalConfig: GlobalConfig;
|
|
140
|
+
export declare function setGlobalConfig(overrideConfig: Partial<GlobalConfig>): void;
|
|
141
|
+
/**
|
|
142
|
+
* Type guard function to test if an action is a asynchronous action.
|
|
143
|
+
*/
|
|
144
|
+
export declare function isAsyncAction<S, DS, F extends (...args: any[]) => any, A, P, FxRes = S>(action: StoreAction<S, F, A, P, DS, FxRes>): action is AsyncAction<S, F, A, P, DS, FxRes>;
|
|
145
|
+
/**
|
|
146
|
+
* Type guard function to test if an action is a synchronous action.
|
|
147
|
+
*/
|
|
148
|
+
export declare function isSimpleSyncAction<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = S>(action: StoreAction<S, F, A, P, DS, FxRes>): action is SimpleSyncAction<S, F, P, DS, FxRes>;
|
|
149
|
+
/**
|
|
150
|
+
* Type guard function to test if an action is a synchronous action.
|
|
151
|
+
*/
|
|
152
|
+
export declare function isSyncAction<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = S>(action: StoreAction<S, F, A, P, DS, FxRes>): action is SyncAction<S, F, A, P, DS, FxRes>;
|
|
153
|
+
export declare function isAsyncGetPromiseAction<S, DS, F extends (...args: any[]) => any, A, P, FxRes = S>(action: StoreAction<S, F, A, P, DS, FxRes>): action is AsyncActionPromise<S, F, A, P, DS, FxRes>;
|
|
154
|
+
export declare function isAsyncGetPromiseGetAction<S, DS, F extends (...args: any[]) => any, A, P, FxRes = S>(action: StoreAction<S, F, A, P, DS, FxRes>): action is AsyncActionPromiseGet<S, F, A, P, DS, FxRes>;
|
|
155
|
+
/** @internal */
|
|
156
|
+
export declare function computeAsyncActionInput<S, DS, F extends (...args: any[]) => any, A, P, FxRes = S>(action: AsyncAction<S, F, A, P, DS, FxRes>): AsyncActionPromise<S, F, A, P, DS, FxRes>;
|
|
157
|
+
/** @internal */
|
|
158
|
+
export declare function buildLoadingMap<A>(source: InternalLoadingMap<A>, actionName: keyof A, promiseId: string, loading: boolean): InternalLoadingMap<A>;
|
|
159
|
+
/** @internal */
|
|
160
|
+
export declare function updateErrorMap<A>(source: ErrorParallelMap<A>, actionName: keyof A, promiseId: string, error: Error): ErrorParallelMap<A>;
|
|
161
|
+
export declare class ParallelActionError extends Error {
|
|
162
|
+
promiseIds: PromiseIdErrorMap;
|
|
163
|
+
constructor(promiseIds: PromiseIdErrorMap);
|
|
164
|
+
}
|
|
165
|
+
export declare function buildErrorMap<A>(map: ErrorParallelMap<A>): ErrorMap<A>;
|
|
166
|
+
/** @internal */
|
|
167
|
+
export declare function retryPromiseDecorator<S, DS, F extends (...args: any[]) => Promise<any>, A, P>(promiseProvider: PromiseProvider<S, DS, F, A, P>, maxCalls?: number, delay?: number, isRetryError?: (e: Error) => boolean): PromiseProvider<S, DS, F, A, P>;
|
|
168
|
+
export type Ref<P> = {
|
|
169
|
+
current: P;
|
|
170
|
+
};
|
|
171
|
+
/** @internal */
|
|
172
|
+
export declare function createRef<U>(init?: U): Ref<U>;
|
|
173
|
+
/** @internal */
|
|
174
|
+
export declare function buildInvocationContextBase<S, DS, P>(stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>): ContextWithDerived<S, DS, P>;
|
|
175
|
+
/** @internal */
|
|
176
|
+
export declare function buildOnMountInvocationContext<S, DS, A, P>(stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, actionsRef: Ref<A>): OnMountInvocationContext<S, A, P>;
|
|
177
|
+
/** @internal */
|
|
178
|
+
export declare function buildOnUnMountInvocationContext<S, DS, A, P>(stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, abortedActions: AbortedActions<A>): OnUnMountInvocationContext<S, A, P>;
|
|
179
|
+
/** @internal */
|
|
180
|
+
export declare function buildOnPropChangeEffects<S, DS, P>(stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, indices: number[], index: number, isInit: boolean, getInitialState: (p: P) => S): OnPropsChangeEffectsContext<S, DS, P>;
|
|
181
|
+
/** @internal */
|
|
182
|
+
export declare function addStateToContext<T, S>(ctx: T, stateRef: Ref<S>): T & ContextState<S>;
|
|
183
|
+
/** @internal */
|
|
184
|
+
export declare function addContextActions<T, A>(ctx: T, actionsRef: Ref<A>): T & InvocationContextActions<A>;
|
|
185
|
+
/** @internal */
|
|
186
|
+
export declare function isFuncConfig<S, A extends DecoratedActions, P = {}, DS = {}>(config: StoreConfig<S, A, P, DS>): config is StoreConfigFunc<S, A, P, DS>;
|
|
187
|
+
/** @internal */
|
|
188
|
+
export declare function decorateSimpleSyncAction<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(actionName: keyof A, action: SimpleSyncAction<S, F, P, DS>, stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, initializedRef: Ref<boolean>, options: StoreOptions<S, A, P, DS>, setState: SetStateFunc<S, A>): (...args: Parameters<F>) => void;
|
|
189
|
+
/** @internal */
|
|
190
|
+
export declare function decorateSyncAction<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(actionName: keyof A, action: SyncAction<S, F, A, P, DS>, stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, actionsRef: Ref<A>, initializedRef: Ref<boolean>, timeoutMap: Ref<TimeoutMap<A>>, options: StoreOptions<S, A, P, any>, setState: SetStateFunc<S, A>, clearError: ClearErrorFunc<A>): (...args: Parameters<F>) => void;
|
|
191
|
+
/** @internal */
|
|
192
|
+
export declare function decorateAsyncAction<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(context: AsyncActionExecContext<S, DS, F, A, P>): (...args: Parameters<F>) => Promise<any>;
|
|
193
|
+
/** @internal */
|
|
194
|
+
export declare function isLoadingImpl<A, K extends keyof A>(loadingMap: InternalLoadingMap<A>, ...props: (K | [K, string])[]): boolean;
|
|
195
|
+
export declare const DEFAULT_PROMISE_ID = "__def__";
|
|
196
|
+
/** @internal */
|
|
197
|
+
export declare function areSameArgs(args1: any[], args2: any[]): boolean;
|
|
198
|
+
/** @internal */
|
|
199
|
+
export declare function computeDerivedValues<S, A, P, DS>(s: Ref<S>, p: Ref<P>, derivedStateRef: Ref<DerivedState<DS>>, options: StoreOptions<S, A, P, DS>): boolean;
|
|
200
|
+
/** @internal */
|
|
201
|
+
export declare function fixDerivedDeps<S, A, P, DS>(options: StoreOptions<S, A, P, DS>): void;
|
|
202
|
+
/** @internal */
|
|
203
|
+
export declare function onPropChange<S, P, A, DS>(stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, oldProps: P, actionsRef: Ref<A>, options: StoreOptions<S, A, P, DS>, getInitialState: (p: P) => S, setState: SetStateFunc<S, A>, isInit: boolean, isDeferred: boolean): void;
|
|
204
|
+
/** @internal */
|
|
205
|
+
export declare function runMiddlewares<S, A extends DecoratedActions, P>(middlewares: Middleware<S, A, P>[], oldState: S, newState: S, loading: boolean, actionName: keyof A, actionType: 'preEffects' | 'effects' | 'errorEffects' | null, isAsync: boolean, actionCtx: any): {
|
|
206
|
+
newState: S;
|
|
207
|
+
newLoading: boolean;
|
|
208
|
+
};
|
|
209
|
+
export {};
|