@evlop/commons 1.0.182 → 1.0.183

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,6 +4,6 @@ import { Action } from './useActionable';
4
4
  * @param action action object ot function
5
5
  * @returns function
6
6
  */
7
- export declare const useAction: (action?: Action) => (event?: any) => any;
7
+ export declare const useAction: (action?: Action) => (event: any) => void;
8
8
  export default useAction;
9
9
  //# sourceMappingURL=useAction.d.ts.map
@@ -13,10 +13,10 @@ export interface ActionObject {
13
13
  callback: Function;
14
14
  }
15
15
  export declare type Action = ActionObject | Function | any;
16
- export declare const useActionableWithNavigator: (navigator: any) => (action: Action) => (event?: any) => any;
16
+ export declare const useActionableWithNavigator: (navigator: any) => (action: Action | Action[]) => (event: any) => void;
17
17
  /**
18
18
  * @description a function to map action into action handeller function
19
19
  */
20
- export declare const useActionable: () => (action: Action) => (event?: any) => any;
20
+ export declare const useActionable: () => (action: Action | Action[]) => (event: any) => void;
21
21
  export default useActionable;
22
22
  //# sourceMappingURL=useActionable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useActionable.d.ts","sourceRoot":"","sources":["../../../src/hooks/useActionable.tsx"],"names":[],"mappings":"AASA;;;;GAIG;AAEF,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IACjC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC5B,QAAQ,EAAE,QAAQ,CAAC;CACtB;AAED,oBAAY,MAAM,GAAG,YAAY,GAAG,QAAQ,GAAG,GAAG,CAAA;AAElD,eAAO,MAAM,0BAA0B,cAAe,GAAG,cAKF,MAAM,cAAc,GAAG,QA8B7E,CAAA;AAED;;GAEG;AACJ,eAAO,MAAM,aAAa,iBAnC8B,MAAM,cAAc,GAAG,QAuC9E,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"useActionable.d.ts","sourceRoot":"","sources":["../../../src/hooks/useActionable.tsx"],"names":[],"mappings":"AASA;;;;GAIG;AAEF,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IACjC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC5B,QAAQ,EAAE,QAAQ,CAAC;CACtB;AAED,oBAAY,MAAM,GAAG,YAAY,GAAG,QAAQ,GAAG,GAAG,CAAA;AAElD,eAAO,MAAM,0BAA0B,cAAe,GAAG,cAkCH,MAAM,GAAG,MAAM,EAAE,aAAa,GAAG,SAUtF,CAAA;AAED;;GAEG;AACJ,eAAO,MAAM,aAAa,iBAf6B,MAAM,GAAG,MAAM,EAAE,aAAa,GAAG,SAmBvF,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -15,7 +15,7 @@ const useActionableWithNavigator = (navigator) => {
15
15
  const dispatch = react_redux_1.useDispatch();
16
16
  const scope = useScope_1.useScope();
17
17
  const template = useTemplate_1.default();
18
- const createActionHandeller = react_1.useCallback((action) => (event) => {
18
+ const handleAction = react_1.useCallback((action, event) => {
19
19
  let actionToUse = action;
20
20
  let scopeActionName = typeof actionToUse === 'string' ? actionToUse : lodash_1.get(actionToUse, 'bindKey');
21
21
  while (scopeActionName) {
@@ -49,6 +49,14 @@ const useActionableWithNavigator = (navigator) => {
49
49
  return callback({ event, navigator, dispatch });
50
50
  }
51
51
  }, [navigator, dispatch, template, scope]);
52
+ const createActionHandeller = react_1.useCallback((action) => (event) => {
53
+ if (Array.isArray(action)) {
54
+ // run all actions in sequence, if any action returns a promise, wait for it to resolve before running the next action
55
+ lodash_1.reduce(action, (promise, actionItem) => promise.then(() => handleAction(actionItem, event)), Promise.resolve());
56
+ return;
57
+ }
58
+ handleAction(action, event);
59
+ }, [handleAction]);
52
60
  return createActionHandeller;
53
61
  };
54
62
  exports.useActionableWithNavigator = useActionableWithNavigator;
@@ -1 +1 @@
1
- {"version":3,"file":"useActionable.js","sourceRoot":"","sources":["../../../src/hooks/useActionable.tsx"],"names":[],"mappings":";;;;;;AAAA,iCAA6C;AAC7C,6CAA0C;AAC1C,mCAAwC;AACxC,iDAA4C;AAC5C,yCAAoC;AACpC,gEAAwC;AACxC,mCAAiC;AAqBzB,MAAM,0BAA0B,GAAG,CAAC,SAAc,EAAE,EAAE;IAC1D,MAAM,QAAQ,GAAG,yBAAW,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAG,mBAAQ,EAAE,CAAC;IACzB,MAAM,QAAQ,GAAG,qBAAW,EAAE,CAAC;IAE/B,MAAM,qBAAqB,GAAI,mBAAW,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,KAAW,EAAE,EAAE;QAC3E,IAAI,WAAW,GAAG,MAAM,CAAC;QACzB,IAAI,eAAe,GAAG,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAElG,OAAO,eAAe,EAAC;YACnB,WAAW,GAAG,YAAG,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;YAC1C,eAAe,GAAG,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;SACjG;QAED,IAAG,OAAO,WAAW,KAAK,UAAU;YAAE,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;QAEhE,IAAG,OAAO,WAAW,KAAK,QAAQ,EAAE;YAChC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,OA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