src/internals/reactools/reduxPatches/bindActionCreators.js
/**
 * This is a very similar implementation to the bindActionCreator in redux.
 * The only difference is that, here we return a promise rather than just returning from the method.
 *
 * @param actionCreator
 * @param dispatch
 * @return {function(): Promise<any>}
 */
This is a very similar implementation to the bindActionCreator in redux.
The only difference is that, here we return a promise rather than just returning from the method.

@param actionCreator
@param dispatch
@return {function(): Promise}
This is a very similar implementation to the bindActionCreator in redux . The only difference is that here we return a promise rather than just returning from the method . @param actionCreator @param dispatch @return { function () : Promise }
function bindActionCreator(actionCreator, dispatch) {
  return function() {
    let args = Array.from(arguments);
    if (actionCreator.appendPromiseHandlers) {
      return new Promise((resolve, reject) => {
        args.push(resolve, reject);
        return dispatch(actionCreator.apply(this, args));
      });
    }
    return dispatch(actionCreator.apply(this, args));
  };
}
function bindActionCreator ( actionCreator , dispatch ) { return function ( ) { let args = Array . from ( arguments ) ; if ( actionCreator . appendPromiseHandlers ) { return new Promise ( ( resolve , reject ) => { args . push ( resolve , reject ) ; return dispatch ( actionCreator . apply ( this , args ) ) ; } ) ; } return dispatch ( actionCreator . apply ( this , args ) ) ; } ; }
This is a very similar implementation to the bindActionCreator in redux.
This is a very similar implementation to the bindActionCreator in redux .
// Clone the arguments into an array, to modify later // First we check if this is an actionCreator made by the reactools factory methods // If so, return a promise, so the components can do, someMethodCall().then().catch() or async await. // We append the resolve and reject calls to the argument list, so a reducer or a middleware can // -call them, after an async operation, to signal the method caller about the status of the operation // Same step as original redux function, but wrapped in the promise constructor // if the appendPromiseHandlers flag is not there, we return the same result as redux bindActionCreator