state-decorator 7.0.0-beta.9-dev → 7.0.0-rc10

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.
Files changed (64) hide show
  1. package/README.md +71 -93
  2. package/development.d.ts +10 -0
  3. package/development.js +2 -0
  4. package/development.js.map +1 -0
  5. package/es/development.d.ts +10 -0
  6. package/es/development.js +2 -0
  7. package/es/development.js.map +1 -0
  8. package/es/graph.d.ts +8 -0
  9. package/es/helpers.d.ts +10 -9
  10. package/es/helpers.js +1 -162
  11. package/es/helpers.js.map +1 -1
  12. package/es/impl.d.ts +20 -32
  13. package/es/impl.js +1 -963
  14. package/es/impl.js.map +1 -1
  15. package/es/index.d.ts +19 -24
  16. package/es/index.js +1 -1013
  17. package/es/index.js.map +1 -1
  18. package/es/middlewares.d.ts +0 -23
  19. package/es/middlewares.js +1 -519
  20. package/es/middlewares.js.map +1 -1
  21. package/es/shallow.d.ts +0 -14
  22. package/es/test.d.ts +7 -21
  23. package/es/test.js +1 -349
  24. package/es/test.js.map +1 -1
  25. package/es/types.d.ts +73 -72
  26. package/es/v5.d.ts +5 -18
  27. package/es/v5.js +1 -301
  28. package/es/v5.js.map +1 -1
  29. package/es/v5_test.d.ts +4 -17
  30. package/es/v5_test.js +1 -392
  31. package/es/v5_test.js.map +1 -1
  32. package/es/v5_types.d.ts +15 -29
  33. package/es/v6.d.ts +7 -3
  34. package/es/v6.js +1 -96
  35. package/es/v6.js.map +1 -1
  36. package/graph.d.ts +8 -0
  37. package/helpers.d.ts +10 -9
  38. package/helpers.js +1 -174
  39. package/helpers.js.map +1 -1
  40. package/impl.d.ts +20 -32
  41. package/impl.js +1 -996
  42. package/impl.js.map +1 -1
  43. package/index.d.ts +19 -24
  44. package/index.js +1 -1044
  45. package/index.js.map +1 -1
  46. package/middlewares.d.ts +0 -23
  47. package/middlewares.js +1 -526
  48. package/middlewares.js.map +1 -1
  49. package/package.json +1 -1
  50. package/shallow.d.ts +0 -14
  51. package/test.d.ts +7 -21
  52. package/test.js +1 -358
  53. package/test.js.map +1 -1
  54. package/types.d.ts +73 -72
  55. package/v5.d.ts +5 -18
  56. package/v5.js +1 -322
  57. package/v5.js.map +1 -1
  58. package/v5_test.d.ts +4 -17
  59. package/v5_test.js +1 -416
  60. package/v5_test.js.map +1 -1
  61. package/v5_types.d.ts +15 -29
  62. package/v6.d.ts +7 -3
  63. package/v6.js +1 -120
  64. package/v6.js.map +1 -1
package/types.d.ts CHANGED
@@ -1,45 +1,31 @@
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
- export declare type PromiseResult<Type> = Type extends Promise<infer X> ? X : null;
16
- export declare type NotifyFunc = (msg: string) => void;
17
- export declare type PromiseIdMap = {
1
+ export type PromiseResult<Type> = Type extends Promise<infer X> ? X : null;
2
+ export type NotifyFunc = (msg: string) => void;
3
+ export type PromiseIdMap = {
18
4
  [promiseId: string]: boolean;
19
5
  };
20
- export declare type LoadingMap<A> = {
6
+ export type LoadingMap<A> = {
21
7
  [pId in keyof A]?: boolean;
22
8
  };
23
- export declare type LoadingParallelMap<A> = {
9
+ export type LoadingParallelMap<A> = {
24
10
  [P in keyof A]?: PromiseIdMap;
25
11
  };
26
- export declare type InternalLoadingMap<A> = LoadingParallelMap<A>;
27
- export declare type LoadingProps<A> = {
12
+ export type InternalLoadingMap<A> = LoadingParallelMap<A>;
13
+ export type LoadingProps<A> = {
28
14
  loading: boolean;
29
15
  loadingMap: LoadingMap<A>;
30
16
  loadingParallelMap: LoadingParallelMap<A>;
31
17
  };
32
- export declare type LoadingMapProps<A> = Pick<LoadingProps<A>, 'loadingMap'>;
33
- export declare type PromiseIdErrorMap = {
18
+ export type LoadingMapProps<A> = Pick<LoadingProps<A>, 'loadingMap'>;
19
+ export type PromiseIdErrorMap = {
34
20
  [promiseId: string]: Error;
35
21
  };
36
- export declare type ErrorMap<A> = {
22
+ export type ErrorMap<A> = {
37
23
  [pId in keyof A]?: Error;
38
24
  };
39
- export declare type ErrorParallelMap<A> = {
25
+ export type ErrorParallelMap<A> = {
40
26
  [P in keyof A]?: PromiseIdErrorMap;
41
27
  };
42
- export declare type ErrorProps<A> = {
28
+ export type ErrorProps<A> = {
43
29
  errorMap: ErrorMap<A>;
44
30
  };
45
31
  export interface DecoratedActions {
@@ -76,12 +62,12 @@ export declare enum ConflictPolicy {
76
62
  */
77
63
  REUSE = "reuse"
78
64
  }
79
- export declare type PromiseProvider<S, DS, F extends (...args: any[]) => any, A, P> = (ctx: GetPromiseInvocationContext<S, DS, F, P, A>) => ReturnType<F> | null;
65
+ export type PromiseProvider<S, DS, F extends (...args: any[]) => any, A, P> = (ctx: GetPromiseInvocationContext<S, DS, F, P, A>) => ReturnType<F> | null;
80
66
  /**
81
67
  * Simple form of a synchronous action.
82
68
  */
83
- export declare type SimpleSyncAction<S, F extends (...args: any[]) => any, P, DS, FxRes = Partial<S>> = (ctx: InvocationContext<S, DS, F, P>) => FxRes | null;
84
- export declare type SyncAction<S, F extends (...args: any[]) => any, A, P, DS, FxRes = Partial<S>> = {
69
+ export type SimpleSyncAction<S, F extends (...args: any[]) => any, P, DS, FxRes = Partial<S>> = (ctx: InvocationContext<S, DS, F, P>) => FxRes | null;
70
+ export type SyncAction<S, F extends (...args: any[]) => any, A, P, DS, FxRes = Partial<S>> = {
85
71
  /**
86
72
  * Function that update the state when the action is called.
87
73
  */
@@ -105,75 +91,75 @@ export declare type SyncAction<S, F extends (...args: any[]) => any, A, P, DS, F
105
91
  * @param promiseId If the action conflict type is <code>ConflictType.PARALLEL</code>, the identifier of the promise.
106
92
  * @returns <code>true</code> if the action is abortable and an action is ongoing, <code>false</code> otherwise.
107
93
  */
108
- export declare type AbortActionCallback<A> = (actionName: keyof A, promiseId?: string) => boolean;
109
- export declare type GetErrorMessage<S, DS, F extends (...args: any[]) => any, P> = (ctx: ErrorMessageInvocationContext<S, DS, F, P>) => string | null;
110
- export declare type ContextState<S> = {
94
+ export type AbortActionCallback<A> = (actionName: keyof A, promiseId?: string) => boolean;
95
+ export type GetErrorMessage<S, DS, F extends (...args: any[]) => any, P> = (ctx: ErrorMessageInvocationContext<S, DS, F, P>) => string | null;
96
+ export type ContextState<S> = {
111
97
  state: S;
112
98
  s: S;
113
99
  };
114
- export declare type ContextDerivedStateState<DS> = {
100
+ export type ContextDerivedStateState<DS> = {
115
101
  derived: DS;
116
102
  ds: DS;
117
103
  };
118
- export declare type ContextBase<S, P> = ContextState<S> & {
104
+ export type ContextBase<S, P> = ContextState<S> & {
119
105
  props: P;
120
106
  p: P;
121
107
  };
122
- export declare type ContextWithDerived<S, DS, P> = ContextBase<S, P> & ContextDerivedStateState<DS>;
123
- export declare type InvocationContextActions<A> = {
108
+ export type ContextWithDerived<S, DS, P> = ContextBase<S, P> & ContextDerivedStateState<DS>;
109
+ export type InvocationContextActions<A> = {
124
110
  actions: A;
125
111
  a: A;
126
112
  };
127
- export declare type WarningNotifyFunc = {
113
+ export type WarningNotifyFunc = {
128
114
  notifyWarning?: NotifyFunc;
129
115
  };
130
- export declare type InvocationContext<S, DS, F extends (...args: any[]) => any, P> = ContextWithDerived<S, DS, P> & {
116
+ export type InvocationContext<S, DS, F extends (...args: any[]) => any, P> = ContextWithDerived<S, DS, P> & {
131
117
  args: Parameters<F>;
132
118
  promiseId: string;
133
119
  };
134
- export declare type EffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P> = InvocationContext<S, DS, F, P> & {
120
+ export type EffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P> = InvocationContext<S, DS, F, P> & {
135
121
  result: PromiseResult<ReturnType<F>>;
136
122
  res: PromiseResult<ReturnType<F>>;
137
123
  };
138
- export declare type GetPromiseInvocationContext<S, DS, F extends (...args: any[]) => any, P, A> = InvocationContextActions<A> & InvocationContext<S, DS, F, P> & {
124
+ export type GetPromiseInvocationContext<S, DS, F extends (...args: any[]) => any, P, A> = InvocationContextActions<A> & InvocationContext<S, DS, F, P> & {
139
125
  abortSignal: AbortSignal;
140
126
  };
141
- export declare type ErrorEffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P> = InvocationContext<S, DS, F, P> & {
127
+ export type ErrorEffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P> = InvocationContext<S, DS, F, P> & {
142
128
  error: Error;
143
129
  err: Error;
144
130
  };
145
- export declare type SuccessMessageInvocationContext<S, DS, F extends (...args: any[]) => any, P> = EffectsInvocationContext<S, DS, F, P>;
146
- export declare type ErrorMessageInvocationContext<S, DS, F extends (...args: any[]) => any, P> = ErrorEffectsInvocationContext<S, DS, F, P>;
147
- export declare type ClearErrorFunc<A> = (actionName: keyof A, promiseId?: string) => void;
148
- export declare type ClearError<A> = {
131
+ export type SuccessMessageInvocationContext<S, DS, F extends (...args: any[]) => any, P> = EffectsInvocationContext<S, DS, F, P>;
132
+ export type ErrorMessageInvocationContext<S, DS, F extends (...args: any[]) => any, P> = ErrorEffectsInvocationContext<S, DS, F, P>;
133
+ export type ClearErrorFunc<A> = (actionName: keyof A, promiseId?: string) => void;
134
+ export type ClearError<A> = {
149
135
  clearError: ClearErrorFunc<A>;
150
136
  };
151
- export declare type SideEffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P, A> = EffectsInvocationContext<S, DS, F, P> & InvocationContextActions<A> & WarningNotifyFunc & ClearError<A>;
152
- export declare type ErrorSideEffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P, A> = ErrorEffectsInvocationContext<S, DS, F, P> & InvocationContextActions<A> & WarningNotifyFunc;
153
- export declare type OnMountInvocationContext<S, A, P> = ContextBase<S, P> & InvocationContextActions<A>;
154
- export declare type AbortedActions<A> = Partial<Record<keyof A, string[]>>;
155
- export declare type OnUnMountInvocationContext<S, A, P> = ContextBase<S, P> & {
137
+ export type SideEffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P, A> = EffectsInvocationContext<S, DS, F, P> & InvocationContextActions<A> & WarningNotifyFunc & ClearError<A>;
138
+ export type ErrorSideEffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P, A> = ErrorEffectsInvocationContext<S, DS, F, P> & InvocationContextActions<A> & WarningNotifyFunc;
139
+ export type OnMountInvocationContext<S, A, P> = ContextBase<S, P> & InvocationContextActions<A>;
140
+ export type AbortedActions<A> = Partial<Record<keyof A, string[]>>;
141
+ export type OnUnMountInvocationContext<S, A, P> = ContextBase<S, P> & {
156
142
  abortedActions: AbortedActions<A>;
157
143
  };
158
- export declare type EffectsType = 'preEffects' | 'effects' | 'errorEffects' | 'optimisticEffects' | null;
159
- export declare type MiddlewareActionContext<S, A, P> = {
144
+ export type EffectsType = 'preEffects' | 'effects' | 'errorEffects' | 'optimisticEffects' | null;
145
+ export type MiddlewareActionContext<S, A, P> = {
160
146
  name: keyof A;
161
147
  type: EffectsType;
162
148
  isAsync: boolean;
163
149
  context: InvocationContext<S, any, any, P>;
164
150
  };
165
- export declare type MiddlewareStoreContext<S, A extends DecoratedActions, P> = {
151
+ export type MiddlewareStoreContext<S, A extends DecoratedActions, P> = {
166
152
  actions: StoreActions<S, A, P, any, any>;
167
153
  state: S;
168
154
  setState: (s: S) => void;
169
155
  options: StoreOptions<S, A, P, any>;
170
156
  };
171
- export declare type MiddlewareFactory<S, A extends DecoratedActions, P> = () => Middleware<S, A, P>;
157
+ export type MiddlewareFactory<S, A extends DecoratedActions, P> = () => Middleware<S, A, P>;
172
158
  /**
173
159
  * A state change middleware.
174
160
  * Allow to listen and change a state change on the fly.
175
161
  */
176
- export declare type Middleware<S, A extends DecoratedActions, P> = {
162
+ export type Middleware<S, A extends DecoratedActions, P> = {
177
163
  /**
178
164
  * Initializes the middleware. Called when the store is initializing.
179
165
  */
@@ -190,7 +176,7 @@ export declare type Middleware<S, A extends DecoratedActions, P> = {
190
176
  */
191
177
  destroy: () => void;
192
178
  };
193
- export declare type AsyncActionBase<S, F extends (...args: any[]) => any, A, P, DS, FxRes = Partial<S>> = {
179
+ export type AsyncActionBase<S, F extends (...args: any[]) => any, A, P, DS, FxRes = Partial<S>> = {
194
180
  /**
195
181
  * This action can be aborted. An abortSignal will be injected to the <code>promise</code> / <code>promiseGet</code>.
196
182
  */
@@ -276,13 +262,13 @@ export declare type AsyncActionBase<S, F extends (...args: any[]) => any, A, P,
276
262
  */
277
263
  isTriggerRetryError?: (e: Error) => boolean;
278
264
  };
279
- export declare type AsyncActionPromise<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = Partial<S>> = AsyncActionBase<S, F, A, P, DS, FxRes> & {
265
+ export type AsyncActionPromise<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = Partial<S>> = AsyncActionBase<S, F, A, P, DS, FxRes> & {
280
266
  /**
281
267
  * The request, returns a promise
282
268
  */
283
269
  getPromise: PromiseProvider<S, DS, F, A, P>;
284
270
  };
285
- export declare type AsyncActionPromiseGet<S, F extends (...args: any[]) => any, A, P, DS, FxRes = Partial<S>> = AsyncActionBase<S, F, A, P, DS, FxRes> & {
271
+ export type AsyncActionPromiseGet<S, F extends (...args: any[]) => any, A, P, DS, FxRes = Partial<S>> = AsyncActionBase<S, F, A, P, DS, FxRes> & {
286
272
  /**
287
273
  * The request, returns a promise that is a GET request.
288
274
  * A shortcut to set:
@@ -291,43 +277,48 @@ export declare type AsyncActionPromiseGet<S, F extends (...args: any[]) => any,
291
277
  */
292
278
  getGetPromise: PromiseProvider<S, DS, F, A, P>;
293
279
  };
294
- export declare type AsyncAction<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = Partial<S>> = AsyncActionPromise<S, F, A, P, DS, FxRes> | AsyncActionPromiseGet<S, F, A, P, DS, FxRes>;
295
- export declare type StoreAction<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = Partial<S>> = AsyncAction<S, F, A, P, DS, FxRes> | SimpleSyncAction<S, F, P, DS, FxRes> | SyncAction<S, F, A, P, DS, FxRes>;
280
+ export type AsyncAction<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = Partial<S>> = AsyncActionPromise<S, F, A, P, DS, FxRes> | AsyncActionPromiseGet<S, F, A, P, DS, FxRes>;
281
+ export type StoreAction<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = Partial<S>> = AsyncAction<S, F, A, P, DS, FxRes> | SimpleSyncAction<S, F, P, DS, FxRes> | SyncAction<S, F, A, P, DS, FxRes>;
296
282
  /**
297
283
  * S: The type of the state
298
284
  * A: The type of the actions to pass to the children (used to check keys only).
299
285
  */
300
- export declare type StoreActions<S, A extends DecoratedActions, P = {}, DS = {}, FxRes = Partial<S>> = {
286
+ export type StoreActions<S, A extends DecoratedActions, P = {}, DS = {}, FxRes = Partial<S>> = {
301
287
  [Prop in keyof A]: StoreAction<S, A[Prop], A, P, DS, FxRes>;
302
288
  };
303
- export declare type OnPropsChangeEffectsContext<S, DS, P> = ContextWithDerived<S, DS, P> & {
289
+ export type OnPropsChangeEffectsContext<S, DS, P> = ContextWithDerived<S, DS, P> & {
304
290
  indices: number[];
305
291
  index: number;
306
292
  isInit: boolean;
307
293
  getInitialState: (p: P) => S;
308
294
  };
309
- export declare type OnPropsChangeSideEffectsContext<S, P, A, DS = {}> = OnPropsChangeEffectsContext<S, DS, P> & {
295
+ export type OnPropsChangeSideEffectsContext<S, P, A, DS = {}> = OnPropsChangeEffectsContext<S, DS, P> & {
310
296
  actions: A;
311
297
  a: A;
312
298
  };
313
- declare type DerivedStateOption<S, P, DS> = {
299
+ type DerivedStateOption<S, P, DS> = {
314
300
  [k in keyof DS]: {
315
- getDeps: (ctx: ContextBase<S, P>) => any[];
316
- get: (ctx: ContextBase<S, P>) => DS[k];
301
+ getDeps?: (ctx: ContextBase<S, P>) => any[];
302
+ get: (ctx: ContextBase<S, P> & ContextDerivedStateState<DS>) => DS[k];
303
+ derivedDeps?: (keyof DS)[];
317
304
  };
318
305
  };
319
- export declare type OnPropsChangeOptions<S, DS, A, P> = {
306
+ export type OnPropsChangeOptions<S, DS, A, P, FxRes = Partial<S>> = {
320
307
  onMount?: boolean;
321
308
  onMountDeferred?: boolean;
322
309
  getDeps: (p: P) => any[];
323
- effects?: (ctx: OnPropsChangeEffectsContext<S, DS, P>) => Partial<S>;
310
+ effects?: (ctx: OnPropsChangeEffectsContext<S, DS, P>) => FxRes;
324
311
  sideEffects?: (ctx: OnPropsChangeSideEffectsContext<S, P, A>) => void;
325
312
  };
326
- export declare type StoreOptions<S, A, P = {}, DS = {}> = {
313
+ export type StoreOptions<S, A, P = {}, DS = {}, FxRes = Partial<S>> = {
327
314
  /**
328
315
  * The state decorator name. Use in debug traces to identify the useStateDecorator instance.
329
316
  */
330
317
  name?: string;
318
+ /**
319
+ * In development only (NODE_ENV="development"), activates state changes traces on the console.
320
+ */
321
+ logEnabled?: boolean;
331
322
  /**
332
323
  * Indicates that all asynchronous actions errors are managed externally.
333
324
  * Same as setting isErrorManaged to true for all actions.
@@ -342,7 +333,7 @@ export declare type StoreOptions<S, A, P = {}, DS = {}> = {
342
333
  /**
343
334
  * One or several configurations of inbound properties change managements.
344
335
  */
345
- onPropsChange?: OnPropsChangeOptions<S, DS, A, P> | OnPropsChangeOptions<S, DS, A, P>[];
336
+ onPropsChange?: OnPropsChangeOptions<S, DS, A, P, FxRes> | OnPropsChangeOptions<S, DS, A, P, FxRes>[];
346
337
  /**
347
338
  * The callback function called if an asynchronous function succeeded and a success messsage is defined.
348
339
  */
@@ -372,10 +363,20 @@ export declare type StoreOptions<S, A, P = {}, DS = {}> = {
372
363
  * Compute derived state
373
364
  */
374
365
  derivedState?: DerivedStateOption<S, P, DS>;
366
+ /**
367
+ * Disable auto spread of state on effects (v6 behavior).
368
+ */
369
+ fullStateEffects?: boolean;
375
370
  };
376
- export declare type StoreConfig<S, A extends DecoratedActions, P = {}, DS = {}> = {
377
- getInitialState: S | ((p: P) => S);
371
+ type StoreConfigBase<S, A extends DecoratedActions, P = {}, DS = {}> = {
378
372
  actions: StoreActions<S, A, P, DS>;
379
373
  middlewares?: MiddlewareFactory<S, A, P>[];
380
374
  } & StoreOptions<S, A, P, DS>;
375
+ type StoreConfigObj<S, A extends DecoratedActions, P = {}, DS = {}> = StoreConfigBase<S, A, P, DS> & {
376
+ initialState: S;
377
+ };
378
+ type StoreConfigFunc<S, A extends DecoratedActions, P = {}, DS = {}> = StoreConfigBase<S, A, P, DS> & {
379
+ getInitialState: (p: P) => S;
380
+ };
381
+ export type StoreConfig<S, A extends DecoratedActions, P = {}, DS = {}> = StoreConfigObj<S, A, P, DS> | StoreConfigFunc<S, A, P, DS>;
381
382
  export {};
package/v5.d.ts CHANGED
@@ -1,21 +1,8 @@
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 { DecoratedActions, MiddlewareFactory } from './types';
16
- import { setGlobalConfig, ConflictPolicy } from './index';
17
- import { AdvancedSynchAction, AsynchActionPromiseGet, StateDecoratorAction, StateDecoratorActions, StateDecoratorOptions, AsynchActionPromise, SynchAction, LoadingMap, LoadingProps, LoadingMapParallelActions, AsynchAction } from './v5_types';
18
- export { AdvancedSynchAction, AsynchActionPromiseGet, StateDecoratorAction, StateDecoratorActions, StateDecoratorOptions, AsynchActionPromise, SynchAction, LoadingMap, LoadingMapParallelActions, LoadingProps, ConflictPolicy, setGlobalConfig, };
1
+ import type { DecoratedActions, MiddlewareFactory } from './types';
2
+ import { ConflictPolicy } from './types';
3
+ import { setGlobalConfig } from './index';
4
+ import type { AdvancedSynchAction, AsynchActionPromiseGet, StateDecoratorAction, StateDecoratorActions, StateDecoratorOptions, AsynchActionPromise, SynchAction, LoadingMap, LoadingProps, LoadingMapParallelActions, AsynchAction } from './v5_types';
5
+ export type { AdvancedSynchAction, AsynchActionPromiseGet, StateDecoratorAction, StateDecoratorActions, StateDecoratorOptions, AsynchActionPromise, SynchAction, LoadingMap, LoadingMapParallelActions, LoadingProps, ConflictPolicy, setGlobalConfig, };
19
6
  /**
20
7
  * Type guard function to test if an action is a asynchronous action.
21
8
  */
package/v5.js CHANGED
@@ -1,323 +1,2 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var index = require('./index');
6
- var react = require('react');
7
- var middlewares = require('./middlewares');
8
-
9
- /*! *****************************************************************************
10
- Copyright (c) Microsoft Corporation.
11
-
12
- Permission to use, copy, modify, and/or distribute this software for any
13
- purpose with or without fee is hereby granted.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
16
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
17
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
18
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
19
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
20
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21
- PERFORMANCE OF THIS SOFTWARE.
22
- ***************************************************************************** */
23
-
24
- var __assign = function() {
25
- __assign = Object.assign || function __assign(t) {
26
- for (var s, i = 1, n = arguments.length; i < n; i++) {
27
- s = arguments[i];
28
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
29
- }
30
- return t;
31
- };
32
- return __assign.apply(this, arguments);
33
- };
34
-
35
- /*! *****************************************************************************
36
- Copyright (c) GlobalSport SAS.
37
-
38
- Permission to use, copy, modify, and/or distribute this software for any
39
- purpose with or without fee is hereby granted.
40
-
41
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
42
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
43
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
44
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
45
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
46
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
47
- PERFORMANCE OF THIS SOFTWARE.
48
- ***************************************************************************** */
49
- function isAsyncActionPromise(action) {
50
- return !(action instanceof Function) && action.hasOwnProperty('promise');
51
- }
52
- function isAsyncActionPromiseGet(action) {
53
- return !(action instanceof Function) && action.hasOwnProperty('promiseGet');
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
- function convertV5Actions(sourceActions) {
80
- var actionNames = Object.keys(sourceActions);
81
- return actionNames.reduce(function (acc, actionName) {
82
- var sourceAction = sourceActions[actionName];
83
- if (isSyncAction(sourceAction)) {
84
- acc[actionName] = function (ctx) {
85
- return sourceAction(ctx.s, ctx.args, ctx.p);
86
- };
87
- }
88
- else if (isAdvancedSyncAction(sourceAction)) {
89
- var action = {
90
- effects: function (ctx) {
91
- return sourceAction.action(ctx.s, ctx.args, ctx.p);
92
- },
93
- };
94
- if (sourceAction.onActionDone) {
95
- action.sideEffects = function (_a) {
96
- var s = _a.s, p = _a.p, args = _a.args, a = _a.a, notifyWarning = _a.notifyWarning;
97
- sourceAction.onActionDone(s, args, p, a, notifyWarning);
98
- };
99
- }
100
- acc[actionName] = action;
101
- }
102
- else if (isAsyncActionPromise(sourceAction) || isAsyncActionPromiseGet(sourceAction)) {
103
- var asyncAction_1;
104
- if (isAsyncActionPromiseGet(sourceAction)) {
105
- asyncAction_1 = {
106
- getPromise: function (_a) {
107
- var s = _a.s, p = _a.p, a = _a.a, args = _a.args, abortSignal = _a.abortSignal;
108
- return sourceAction.promiseGet(args, s, p, a, abortSignal);
109
- },
110
- retryCount: 3,
111
- conflictPolicy: index.ConflictPolicy.REUSE,
112
- };
113
- }
114
- else {
115
- asyncAction_1 = {
116
- getPromise: function (_a) {
117
- var s = _a.s, p = _a.p, a = _a.a, args = _a.args, abortSignal = _a.abortSignal;
118
- return sourceAction.promise(args, s, p, a, abortSignal);
119
- },
120
- };
121
- }
122
- [
123
- 'abortable',
124
- 'conflictPolicy',
125
- 'getPromiseId',
126
- 'isTriggerRetryError',
127
- 'rejectPromiseOnError',
128
- 'retryCount',
129
- 'debounceTimeout',
130
- 'debounceSideEffectsTimeout',
131
- 'retryDelaySeed',
132
- ].forEach(function (prop) {
133
- if (sourceAction[prop] != null) {
134
- asyncAction_1[prop] = sourceAction[prop];
135
- }
136
- });
137
- if (sourceAction.successMessage) {
138
- asyncAction_1.getSuccessMessage = function () { return sourceAction.successMessage; };
139
- }
140
- if (sourceAction.errorMessage) {
141
- asyncAction_1.getSuccessMessage = function () { return sourceAction.errorMessage; };
142
- }
143
- if (sourceAction.getSuccessMessage) {
144
- asyncAction_1.getSuccessMessage = function (_a) {
145
- var res = _a.res, args = _a.args, p = _a.p;
146
- return sourceAction.getSuccessMessage(res, args, p);
147
- };
148
- }
149
- if (sourceAction.getErrorMessage) {
150
- asyncAction_1.getErrorMessage = function (_a) {
151
- var err = _a.err, args = _a.args, p = _a.p;
152
- return sourceAction.getErrorMessage(err, args, p);
153
- };
154
- }
155
- if (sourceAction.preReducer) {
156
- asyncAction_1.preEffects = function (_a) {
157
- var s = _a.s, p = _a.p, args = _a.args;
158
- return sourceAction.preReducer(s, args, p);
159
- };
160
- }
161
- if (sourceAction.optimisticReducer) {
162
- asyncAction_1.optimisticEffects = function (_a) {
163
- var s = _a.s, p = _a.p, args = _a.args;
164
- return sourceAction.optimisticReducer(s, args, p);
165
- };
166
- }
167
- if (sourceAction.reducer) {
168
- asyncAction_1.effects = function (_a) {
169
- var s = _a.s, res = _a.res, p = _a.p, args = _a.args;
170
- return sourceAction.reducer(s, res, args, p);
171
- };
172
- }
173
- if (sourceAction.errorReducer) {
174
- asyncAction_1.errorEffects = function (_a) {
175
- var s = _a.s, err = _a.err, p = _a.p, args = _a.args;
176
- return sourceAction.errorReducer(s, err, args, p);
177
- };
178
- }
179
- if (sourceAction.onDone) {
180
- asyncAction_1.sideEffects = function (_a) {
181
- var s = _a.s, res = _a.res, p = _a.p, args = _a.args, a = _a.a, notifyWarning = _a.notifyWarning;
182
- return sourceAction.onDone(s, res, args, p, a, notifyWarning);
183
- };
184
- }
185
- if (sourceAction.onFail) {
186
- asyncAction_1.errorSideEffects = function (_a) {
187
- var s = _a.s, err = _a.err, p = _a.p, args = _a.args, a = _a.a, notifyWarning = _a.notifyWarning;
188
- return sourceAction.onFail(s, err, args, p, a, notifyWarning);
189
- };
190
- }
191
- acc[actionName] = asyncAction_1;
192
- }
193
- return acc;
194
- }, {});
195
- }
196
- function convertV5Options(sourceOptions) {
197
- var opts = {};
198
- var keys = Object.keys(sourceOptions);
199
- var doNotCopyProps = [
200
- 'onPropsChange',
201
- 'onPropsChangeReducer',
202
- 'getPropsRefValues',
203
- 'onMount',
204
- 'initialActionsMarkedLoading',
205
- ];
206
- keys.forEach(function (prop) {
207
- if (!doNotCopyProps.includes(prop)) {
208
- opts[prop] = sourceOptions[prop];
209
- }
210
- });
211
- if (sourceOptions.onMount) {
212
- opts.onMount = function (_a) {
213
- var s = _a.s, p = _a.p, a = _a.a;
214
- return sourceOptions.onMount(a, p, s);
215
- };
216
- }
217
- if (sourceOptions.getPropsRefValues) {
218
- opts.onPropsChange = {
219
- getDeps: sourceOptions.getPropsRefValues,
220
- effects: function (_a) {
221
- var s = _a.s, p = _a.p, indices = _a.indices;
222
- return sourceOptions.onPropsChangeReducer ? sourceOptions.onPropsChangeReducer(s, p, indices) : null;
223
- },
224
- sideEffects: function (_a) {
225
- var s = _a.s, p = _a.p, a = _a.a, indices = _a.indices;
226
- return sourceOptions.onPropsChange == null ? null : sourceOptions.onPropsChange(s, p, a, indices);
227
- },
228
- };
229
- }
230
- if (sourceOptions.initialActionsMarkedLoading) {
231
- opts.initialActionsMarkedLoading = sourceOptions.initialActionsMarkedLoading;
232
- }
233
- return opts;
234
- }
235
- function useStateDecorator(getInitialState, actions, props, options, middlewares$1) {
236
- if (options === void 0) { options = {}; }
237
- var _a = react.useReducer(function (s) { return (s > 100 ? 0 : s + 1); }, 0), forceRefresh = _a[1];
238
- var actionsRef = react.useRef();
239
- var optionsRef = react.useRef();
240
- if (actionsRef.current == null) {
241
- actionsRef.current = convertV5Actions(actions);
242
- }
243
- if (optionsRef.current == null) {
244
- optionsRef.current = convertV5Options(options);
245
- }
246
- var storeRef = react.useRef();
247
- if (storeRef.current == null) {
248
- var middlewareFactories = middlewares$1;
249
- if (options.logEnabled) {
250
- middlewareFactories.push(middlewares.logDetailedEffects());
251
- }
252
- storeRef.current = index.createStore(__assign(__assign({ getInitialState: getInitialState, actions: actionsRef.current }, optionsRef.current), { middlewares: middlewareFactories }));
253
- }
254
- storeRef.current.setProps(props);
255
- react.useLayoutEffect(function () {
256
- return storeRef.current.addStateListener(function () {
257
- forceRefresh();
258
- });
259
- }, []);
260
- var store = storeRef.current;
261
- return {
262
- state: store.state,
263
- actions: store.actions,
264
- loading: store.loading,
265
- loadingMap: store.loadingMap,
266
- loadingParallelMap: store.loadingParallelMap,
267
- abortAction: store.abortAction,
268
- };
269
- }
270
- /**
271
- * Hook to execute a function when hook is mounted.
272
- * @param onMount function to execute on the hook nount
273
- */
274
- function useOnMount(onMount) {
275
- react.useEffect(function () {
276
- var removeListener = onMount();
277
- return typeof removeListener === 'function' ? removeListener : undefined;
278
- }, []);
279
- }
280
- /**
281
- * Hook to execute a function when hook is unmounted.
282
- * @param onUnMount function to execute on the hook nount
283
- */
284
- function useOnUnmount(onUnmount, propList) {
285
- if (propList === void 0) { propList = []; }
286
- react.useEffect(function () {
287
- return onUnmount;
288
- }, propList);
289
- }
290
- /**
291
- * Hook to execute a function when hook is unmounted.
292
- * @param onUnMount function to execute on the hook nount
293
- */
294
- function useOnUnload(onUnload) {
295
- react.useEffect(function () {
296
- document.addEventListener('beforeunload', onUnload);
297
- return function () {
298
- document.removeEventListener('beforeunload', onUnload);
299
- };
300
- }, []);
301
- }
302
-
303
- Object.defineProperty(exports, 'ConflictPolicy', {
304
- enumerable: true,
305
- get: function () {
306
- return index.ConflictPolicy;
307
- }
308
- });
309
- Object.defineProperty(exports, 'setGlobalConfig', {
310
- enumerable: true,
311
- get: function () {
312
- return index.setGlobalConfig;
313
- }
314
- });
315
- exports.default = useStateDecorator;
316
- exports.isAdvancedSyncAction = isAdvancedSyncAction;
317
- exports.isAsyncAction = isAsyncAction;
318
- exports.isAsyncPromiseGetAction = isAsyncPromiseGetAction;
319
- exports.isSyncAction = isSyncAction;
320
- exports.useOnMount = useOnMount;
321
- exports.useOnUnload = useOnUnload;
322
- exports.useOnUnmount = useOnUnmount;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("./index"),r=require("react"),t=function(){return t=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},t.apply(this,arguments)};!function(e){e.REJECT="reject",e.IGNORE="ignore",e.KEEP_LAST="keepLast",e.KEEP_ALL="keepAll",e.PARALLEL="parallel",e.REUSE="reuse"}(e||(e={}));var o=function e(n,r){if(n===r)return!0;if(n&&r&&"object"==typeof n&&"object"==typeof r){if(n.constructor!==r.constructor)return!1;var t,o,s;if(Array.isArray(n)){if((t=n.length)!=r.length)return!1;for(o=t;0!=o--;)if(!e(n[o],r[o]))return!1;return!0}if(n.constructor===RegExp)return n.source===r.source&&n.flags===r.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===r.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===r.toString();if((t=(s=Object.keys(n)).length)!==Object.keys(r).length)return!1;for(o=t;0!=o--;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=t;0!=o--;){var i=s[o];if(!e(n[i],r[i]))return!1}return!0}return n!=n&&r!=r},s=null;function i(e){return!(e instanceof Function)&&e.hasOwnProperty("promiseGet")}function u(e){return e instanceof Function}function c(e){return!(e instanceof Function||e.hasOwnProperty("promise")||e.hasOwnProperty("promiseGet"))}function a(n){return Object.keys(n).reduce((function(r,t){var o=n[t];if(u(o))r[t]=function(e){return o(e.s,e.args,e.p)};else if(c(o)){var s={effects:function(e){return o.action(e.s,e.args,e.p)}};o.onActionDone&&(s.sideEffects=function(e){var n=e.s,r=e.p,t=e.args,s=e.a,i=e.notifyWarning;o.onActionDone(n,t,r,s,i)}),r[t]=s}else if(function(e){return!(e instanceof Function)&&e.hasOwnProperty("promise")}(o)||i(o)){var a;a=i(o)?{getPromise:function(e){var n=e.s,r=e.p,t=e.a,s=e.args,i=e.abortSignal;return o.promiseGet(s,n,r,t,i)},retryCount:3,conflictPolicy:e.REUSE}:{getPromise:function(e){var n=e.s,r=e.p,t=e.a,s=e.args,i=e.abortSignal;return o.promise(s,n,r,t,i)}},["abortable","conflictPolicy","getPromiseId","isTriggerRetryError","rejectPromiseOnError","retryCount","debounceTimeout","debounceSideEffectsTimeout","retryDelaySeed"].forEach((function(e){null!=o[e]&&(a[e]=o[e])})),o.successMessage&&(a.getSuccessMessage=function(){return o.successMessage}),o.errorMessage&&(a.getSuccessMessage=function(){return o.errorMessage}),o.getSuccessMessage&&(a.getSuccessMessage=function(e){var n=e.res,r=e.args,t=e.p;return o.getSuccessMessage(n,r,t)}),o.getErrorMessage&&(a.getErrorMessage=function(e){var n=e.err,r=e.args,t=e.p;return o.getErrorMessage(n,r,t)}),o.preReducer&&(a.preEffects=function(e){var n=e.s,r=e.p,t=e.args;return o.preReducer(n,t,r)}),o.optimisticReducer&&(a.optimisticEffects=function(e){var n=e.s,r=e.p,t=e.args;return o.optimisticReducer(n,t,r)}),o.reducer&&(a.effects=function(e){var n=e.s,r=e.res,t=e.p,s=e.args;return o.reducer(n,r,s,t)}),o.errorReducer&&(a.errorEffects=function(e){var n=e.s,r=e.err,t=e.p,s=e.args;return o.errorReducer(n,r,s,t)}),o.onDone&&(a.sideEffects=function(e){var n=e.s,r=e.res,t=e.p,s=e.args,i=e.a,u=e.notifyWarning;return o.onDone(n,r,s,t,i,u)}),o.onFail&&(a.errorSideEffects=function(e){var n=e.s,r=e.err,t=e.p,s=e.args,i=e.a,u=e.notifyWarning;return o.onFail(n,r,s,t,i,u)}),r[t]=a}return r}),{})}"development"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV||(s=function(e){return void 0===e&&(e=console),function(){var n="",r=e,t=function(e,n){var r;if(n!==e){var t=null!=e?typeof e:typeof n;if("number"===t||"string"===t||"boolean"===t)r="".concat(e," => ").concat(""===n?'""':n);else if(e&&e.length||n&&n.length)if(null==e)r="was ".concat(e,", now contains ").concat(n.length," element(s)");else if(null==n)r="contained ".concat(e.length," element(s), now is ").concat(n);else if(0===e.length)r="was empty, now contains ".concat(n.length," elements");else if(0===n.length)r="contained ".concat(e.length," elements, now is empty");else{var s=n.filter((function(n){return!e.find((function(e){return o(n,e)}))})),i=e.filter((function(e){return!n.find((function(n){return o(e,n)}))}));s.length>10&&(s="".concat(s.length," element(s) added")),i.length>10&&(i="".concat(i.length," element(s) removed")),r={added:s,removed:i}}else r=n}return r},s=function(e){return"string"==typeof e?'"'.concat(e,'"'):e};return{init:function(t){var o,i;n=(null===(o=t.options)||void 0===o?void 0:o.name)?"[".concat(null===(i=t.options)||void 0===i?void 0:i.name,"]"):"";var u=t.state;e.group(n,"initialState"),Object.keys(u).forEach((function(e){r.log(e,":",s(u[e]))})),e.groupEnd()},destroy:null,effects:function(e,o,i,u){var c,a=null===(c=e.context)||void 0===c?void 0:c.args,f=[n,e.name.toString()];if(e.isAsync&&("preEffects"===e.type?f.push(u?"START":"CANCELLED"):"effects"===e.type?f.push("DONE"):f.push("FAILED")),null!=i||a&&0!==Object.keys(a).length?r.group.apply(r,f):r.log.apply(r,f),a&&Object.keys(a).length>0&&(r.group("Arguments"),a.forEach((function(e){r.log(e,":",s(e))})),r.groupEnd()),null!=i){if(r.groupCollapsed("Before"),null==o)r.log("was null");else Object.keys(o).forEach((function(e){r.log(e,":",s(o[e]))}));if(r.groupEnd(),r.groupCollapsed("After"),null==i)r.log("was null");else Object.keys(i).forEach((function(e){r.log(e,":",s(i[e]))}));if(r.groupEnd(),null!=i){r.group("Diff");var l=function(e,n){var r={};return e&&Object.keys(e).forEach((function(o){if(n.hasOwnProperty(o)){var s=e[o],i=n[o],u=t(s,i);u&&(r[o]=u)}else r[o]="was deleted"})),Object.keys(n).forEach((function(o){if(null==e||!e.hasOwnProperty(o)){var s=n[o];r[o]=t(void 0,s)}})),r}(o,i);Object.keys(l).forEach((function(e){return r.log(e,":",l[e])})),r.groupEnd()}}return r.groupEnd(),null}}}}),exports.default=function(e,o,i,u,c){void 0===u&&(u={});var f,l,p,g,d=r.useReducer((function(e){return e>100?0:e+1}),0)[1],v=r.useRef(),y=r.useRef();null==v.current&&(v.current=a(o)),null==y.current&&(y.current=(f=u,l={},p=Object.keys(f),g=["onPropsChange","onPropsChangeReducer","getPropsRefValues","onMount","initialActionsMarkedLoading"],p.forEach((function(e){g.includes(e)||(l[e]=f[e])})),f.onMount&&(l.onMount=function(e){var n=e.s,r=e.p,t=e.a;return f.onMount(t,r,n)}),f.getPropsRefValues&&(l.onPropsChange={getDeps:f.getPropsRefValues,effects:function(e){var n=e.s,r=e.p,t=e.indices;return f.onPropsChangeReducer?f.onPropsChangeReducer(n,r,t):null},sideEffects:function(e){var n=e.s,r=e.p,t=e.a,o=e.indices;return null==f.onPropsChange?null:f.onPropsChange(n,r,t,o)}}),f.initialActionsMarkedLoading&&(l.initialActionsMarkedLoading=f.initialActionsMarkedLoading),l));var E=r.useRef();if(null==E.current){var h=c;u.logEnabled&&h.push(s()),E.current=n.createStore(t(t({getInitialState:e,actions:v.current},y.current),{middlewares:h}))}E.current.setProps(i),r.useLayoutEffect((function(){return E.current.addStateListener((function(){d()}))}),[]);var O=E.current;return{state:O.state,actions:O.actions,loading:O.loading,loadingMap:O.loadingMap,loadingParallelMap:O.loadingParallelMap,abortAction:O.abortAction}},exports.isAdvancedSyncAction=c,exports.isAsyncAction=function(e){return!(e instanceof Function)&&(e.hasOwnProperty("promise")||e.hasOwnProperty("promiseGet"))},exports.isAsyncPromiseGetAction=function(e){return!(e instanceof Function||e.hasOwnProperty("promise")&&e.hasOwnProperty("promiseGet"))},exports.isSyncAction=u,exports.useOnMount=function(e){r.useEffect((function(){var n=e();return"function"==typeof n?n:void 0}),[e])},exports.useOnUnload=function(e){r.useEffect((function(){return document.addEventListener("beforeunload",e),function(){document.removeEventListener("beforeunload",e)}}),[e])},exports.useOnUnmount=function(e,n){void 0===n&&(n=[]),r.useEffect((function(){return e}),[n,e])};
323
2
  //# sourceMappingURL=v5.js.map