function wrapInDispatch(dispatch, { meta, method, args = [], types }) {
  const [requestingType, successType, errorType] = types
  dispatch({
    type: isObject(requestingType) ? requestingType.type : requestingType,
    meta,
    payload: isObject(requestingType) ? requestingType.payload : { args }
  })
  return method(...args)
    .then((payload) => {
      dispatch({
        type: isObject(successType) ? successType.type : successType,
        meta,
        payload: isObject(successType) ? successType.payload : payload
      })
      return payload
    })
    .catch((err) => {
      dispatch({
        type: errorType,
        meta,
        payload: err
      })
      return Promise.reject(err)
    })
}
Wrap method call in dispatched actions
@param {Function} dispatch - Action dispatch function
@param {object} opts - Options object
@param {Function} opts.method - Method to call
@param {Array} opts.args - Arguments to call method with
@param {Array} opts.types - Action types array ([BEFORE, SUCCESS, FAILURE])
@param {object} opts.meta - Meta object
@returns {Promise} Resolves after method is called and success action is dispatched
@private