function acPromise(actionType, pendingPayload, func) {

  // later on I'll make this middleware so i dont need to pass the dispatcher
  // for now I have it stored somewhere
  const dispatch = Process.store.dispatch;

  // first check the function is actually a promise
  // and convert it if it isnt
  const theAction = typeof func.then === 'function' ? func : function() {
    return new Promise(function(resolve, reject) {
      try {
        resolve(func());
      }
      catch (err) {
        console.log("acpromise failure", actionType, err);
        reject(err);
      }
    });
  };

  // now we execute the thing, but dispatch a fullfilled/rejected when done
  theAction()
    .then(function(result) {
      // the result of the original function
      dispatch({
        type: actionType + "_FULFILLED",
        payload: result
      });
    })
    .catch(function(err) {
      dispatch({
        type: actionType + "_REJECTED",
        payload: err
      });
    });

  // what we return is the pending action
  return {
    type: actionType + "_PENDING",
    payload: pendingPayload
  };


}
/**
 * this is a redux action creater that dispatches promises
 * I use this directly instead of the promise-redux middleware
 * because it allows me to sfet an initial value for 
 * the pending state
 * if a function is passed that isn't a promise
 * it will make it into one
 * actionType_PENDING is returned from this
 * and later when the function is completed, actionType_FULFILLED or _REJECTED are dispatched
 * @param {string} actionType the base action type
 * @param {*} pendingPayload the payload to dispatch with the _PENDING action
 * @param {func} function the function to execute that should return a promise
 * @return {object} the action to be dispatched
 */
this is a redux action creater that dispatches promises
I use this directly instead of the promise-redux middleware
because it allows me to sfet an initial value for
the pending state
if a function is passed that isn't a promise
it will make it into one
actionType_PENDING is returned from this
and later when the function is completed, actionType_FULFILLED or _REJECTED are dispatched
@param {string} actionType the base action type
@param {*} pendingPayload the payload to dispatch with the _PENDING action
@param {func} function the function to execute that should return a promise
@return {object} the action to be dispatched
this is a redux action creater that dispatches promises I use this directly instead of the promise - redux middleware because it allows me to sfet an initial value for the pending state if a function is passed that isn ' t a promise it will make it into one actionType_PENDING is returned from this and later when the function is completed actionType_FULFILLED or _REJECTED are dispatched @param { string } actionType the base action type @param { * } pendingPayload the payload to dispatch with the _PENDING action @param { func } function the function to execute that should return a promise @return { object } the action to be dispatched
function acPromise(actionType, pendingPayload, func) {
  const dispatch = Process.store.dispatch;
  const theAction = typeof func.then === 'function' ? func : function() {
    return new Promise(function(resolve, reject) {
      try {
        resolve(func());
      }
      catch (err) {
        console.log("acpromise failure", actionType, err);
        reject(err);
      }
    });
  };
  theAction()
    .then(function(result) {
      dispatch({
        type: actionType + "_FULFILLED",
        payload: result
      });
    })
    .catch(function(err) {
      dispatch({
        type: actionType + "_REJECTED",
        payload: err
      });
    });
  return {
    type: actionType + "_PENDING",
    payload: pendingPayload
  };
}
function acPromise ( actionType , pendingPayload , func ) { const dispatch = Process . store . dispatch ; const theAction = typeof func . then === 'function' ? func : function ( ) { return new Promise ( function ( resolve , reject ) { try { resolve ( func ( ) ) ; } catch ( err ) { console . log ( "acpromise failure" , actionType , err ) ; reject ( err ) ; } } ) ; } ; theAction ( ) . then ( function ( result ) { dispatch ( { type : actionType + "_FULFILLED" , payload : result } ) ; } ) . catch ( function ( err ) { dispatch ( { type : actionType + "_REJECTED" , payload : err } ) ; } ) ; return { type : actionType + "_PENDING" , payload : pendingPayload } ; }
this is a redux action creater that dispatches promises
 I use this directly instead of the promise-redux middleware
 because it allows me to sfet an initial value for
 the pending state
 if a function is passed that isn't a promise
 it will make it into one
 actionType_PENDING is returned from this
 and later when the function is completed, actionType_FULFILLED or _REJECTED are dispatched
 @param {string} actionType the base action type
 @param {*} pendingPayload the payload to dispatch with the _PENDING action
 @param {func} function the function to execute that should return a promise
 @return {object} the action to be dispatched
this is a redux action creater that dispatches promises I use this directly instead of the promise - redux middleware because it allows me to sfet an initial value for the pending state if a function is passed that isn ' t a promise it will make it into one actionType_PENDING is returned from this and later when the function is completed actionType_FULFILLED or _REJECTED are dispatched @param { string } actionType the base action type @param { * } pendingPayload the payload to dispatch with the _PENDING action @param { func } function the function to execute that should return a promise @return { object } the action to be dispatched
// later on I'll make this middleware so i dont need to pass the dispatcher // for now I have it stored somewhere // first check the function is actually a promise // and convert it if it isnt // now we execute the thing, but dispatch a fullfilled/rejected when done // the result of the original function // what we return is the pending action