state-decorator 7.0.0-beta.9-dev → 7.0.0-rc1
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 +42 -11
- package/development.d.ts +24 -0
- package/development.js +2 -0
- package/development.js.map +1 -0
- package/es/development.d.ts +24 -0
- package/es/development.js +2 -0
- package/es/development.js.map +1 -0
- package/es/graph.d.ts +8 -0
- package/es/helpers.js +1 -162
- package/es/helpers.js.map +1 -1
- package/es/impl.d.ts +20 -18
- package/es/impl.js +1 -963
- package/es/impl.js.map +1 -1
- package/es/index.d.ts +6 -9
- package/es/index.js +1 -1013
- package/es/index.js.map +1 -1
- package/es/middlewares.d.ts +0 -9
- package/es/middlewares.js +1 -519
- package/es/middlewares.js.map +1 -1
- package/es/test.d.ts +7 -7
- package/es/test.js +1 -349
- package/es/test.js.map +1 -1
- package/es/types.d.ts +70 -58
- package/es/v5.js +1 -301
- package/es/v5.js.map +1 -1
- package/es/v5_test.js +1 -392
- package/es/v5_test.js.map +1 -1
- package/es/v5_types.d.ts +15 -15
- package/es/v6.d.ts +5 -2
- package/es/v6.js +1 -96
- package/es/v6.js.map +1 -1
- package/graph.d.ts +8 -0
- package/helpers.js +1 -174
- package/helpers.js.map +1 -1
- package/impl.d.ts +20 -18
- package/impl.js +1 -996
- package/impl.js.map +1 -1
- package/index.d.ts +6 -9
- package/index.js +1 -1044
- package/index.js.map +1 -1
- package/middlewares.d.ts +0 -9
- package/middlewares.js +1 -526
- package/middlewares.js.map +1 -1
- package/package.json +1 -1
- package/test.d.ts +7 -7
- package/test.js +1 -358
- package/test.js.map +1 -1
- package/types.d.ts +70 -58
- package/v5.js +1 -322
- package/v5.js.map +1 -1
- package/v5_test.js +1 -416
- package/v5_test.js.map +1 -1
- package/v5_types.d.ts +15 -15
- package/v6.d.ts +5 -2
- package/v6.js +1 -120
- package/v6.js.map +1 -1
package/es/impl.d.ts
CHANGED
|
@@ -13,10 +13,10 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
13
13
|
PERFORMANCE OF THIS SOFTWARE.
|
|
14
14
|
***************************************************************************** */
|
|
15
15
|
import { AsyncAction, SimpleSyncAction, SyncAction, StoreAction, AsyncActionPromise, AsyncActionPromiseGet, PromiseProvider, DecoratedActions, InternalLoadingMap, StoreOptions, InvocationContextActions, OnMountInvocationContext, OnPropsChangeEffectsContext, ContextState, Middleware, MiddlewareFactory, ContextWithDerived, PromiseIdErrorMap, ErrorMap, ErrorParallelMap, OnUnMountInvocationContext, AbortedActions, ClearErrorFunc } from './types';
|
|
16
|
-
export
|
|
16
|
+
export type SetStateFunc<S, A> = (newState: S, newLoadingMap: InternalLoadingMap<A>, actionName: keyof A | 'onPropsChange', actionType: 'preEffects' | 'effects' | 'errorEffects' | null, // FIXME
|
|
17
17
|
isAsync: boolean, actionCtx: any, propsChanged: boolean, isInit?: boolean) => void;
|
|
18
18
|
/** @internal */
|
|
19
|
-
export
|
|
19
|
+
export type PromiseMap<A> = {
|
|
20
20
|
[name in keyof A]?: {
|
|
21
21
|
[promiseId: string]: {
|
|
22
22
|
promise: Promise<any>;
|
|
@@ -26,18 +26,18 @@ export declare type PromiseMap<A> = {
|
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
/** @internal */
|
|
29
|
-
export
|
|
29
|
+
export type FutureActions = {
|
|
30
30
|
args: any[];
|
|
31
31
|
resolve: (...args: any[]) => void;
|
|
32
32
|
reject: (...args: any[]) => void;
|
|
33
33
|
timestamp?: number;
|
|
34
34
|
};
|
|
35
35
|
/** @internal */
|
|
36
|
-
export
|
|
36
|
+
export type ConflictActionsMap<A> = {
|
|
37
37
|
[name in keyof A]?: FutureActions[];
|
|
38
38
|
};
|
|
39
39
|
/** @internal */
|
|
40
|
-
export
|
|
40
|
+
export type AsyncActionExecContext<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P> = {
|
|
41
41
|
actionName: keyof A;
|
|
42
42
|
action: AsyncActionPromise<S, F, A, P, DS>;
|
|
43
43
|
stateRef: Ref<S>;
|
|
@@ -54,19 +54,19 @@ export declare type AsyncActionExecContext<S, DS, F extends (...args: any[]) =>
|
|
|
54
54
|
clearError: ClearErrorFunc<A>;
|
|
55
55
|
};
|
|
56
56
|
/** @internal */
|
|
57
|
-
export
|
|
57
|
+
export type TimeoutMap<A> = {
|
|
58
58
|
[name in keyof A]?: any;
|
|
59
59
|
};
|
|
60
|
-
export
|
|
61
|
-
export
|
|
62
|
-
export
|
|
63
|
-
export
|
|
64
|
-
export
|
|
65
|
-
|
|
60
|
+
export type NotifyFunc = (msg: string) => void;
|
|
61
|
+
export type CloneFunction = <C>(obj: C) => C;
|
|
62
|
+
export type ComparatorFunction = <C>(obj1: C, Obj2: C) => boolean;
|
|
63
|
+
export type RetryOnErrorFunction = (error: any) => boolean;
|
|
64
|
+
export type AsyncErrorHandler = (error: any, isHandled: boolean, state: any, props: any, actionName: string, args: any[]) => void;
|
|
65
|
+
type DerivedStateMap<DS> = {
|
|
66
66
|
[name in keyof DS]?: any[];
|
|
67
67
|
};
|
|
68
68
|
/** @internal */
|
|
69
|
-
export
|
|
69
|
+
export type DerivedState<DS> = {
|
|
70
70
|
state: DS;
|
|
71
71
|
deps: DerivedStateMap<DS>;
|
|
72
72
|
};
|
|
@@ -84,7 +84,7 @@ export declare class EffectError extends Error {
|
|
|
84
84
|
/**
|
|
85
85
|
* Global configuration, shared with all stores.
|
|
86
86
|
*/
|
|
87
|
-
export
|
|
87
|
+
export type GlobalConfig = {
|
|
88
88
|
/**
|
|
89
89
|
* Clone function.
|
|
90
90
|
* Used to clone state and props when managing optimistic reducer and conflicting actions.
|
|
@@ -169,7 +169,7 @@ export declare class ParallelActionError extends Error {
|
|
|
169
169
|
export declare function buildErrorMap<A>(map: ErrorParallelMap<A>): ErrorMap<A>;
|
|
170
170
|
/** @internal */
|
|
171
171
|
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>;
|
|
172
|
-
export
|
|
172
|
+
export type Ref<P> = {
|
|
173
173
|
current: P;
|
|
174
174
|
};
|
|
175
175
|
/** @internal */
|
|
@@ -181,13 +181,13 @@ export declare function buildOnMountInvocationContext<S, DS, A, P>(stateRef: Ref
|
|
|
181
181
|
/** @internal */
|
|
182
182
|
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>;
|
|
183
183
|
/** @internal */
|
|
184
|
-
export declare function buildOnPropChangeEffects<S, DS, P>(stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, indices: number[], index: number, isInit: boolean, getInitialState:
|
|
184
|
+
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>;
|
|
185
185
|
/** @internal */
|
|
186
186
|
export declare function addStateToContext<T, S>(ctx: T, stateRef: Ref<S>): T & ContextState<S>;
|
|
187
187
|
/** @internal */
|
|
188
188
|
export declare function addContextActions<T, A>(ctx: T, actionsRef: Ref<A>): T & InvocationContextActions<A>;
|
|
189
189
|
/** @internal */
|
|
190
|
-
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>, setState: SetStateFunc<S, A>): (...args: Parameters<F>) => void;
|
|
190
|
+
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;
|
|
191
191
|
/** @internal */
|
|
192
192
|
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;
|
|
193
193
|
/** @internal */
|
|
@@ -200,7 +200,9 @@ export declare function areSameArgs(args1: any[], args2: any[]): boolean;
|
|
|
200
200
|
/** @internal */
|
|
201
201
|
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;
|
|
202
202
|
/** @internal */
|
|
203
|
-
export declare function
|
|
203
|
+
export declare function fixDerivedDeps<S, A, P, DS>(options: StoreOptions<S, A, P, DS>): void;
|
|
204
|
+
/** @internal */
|
|
205
|
+
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
206
|
/** @internal */
|
|
205
207
|
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
208
|
newState: S;
|