resources/assets/js/app-v1/utils/redux/utils/createRequestAction.js
/**
 * 
 * @param {string} moduleId 
 * @param {string} restAction Either of: LOAD | CREATE | UPDATE | DELETE. 
 * You can also import restActionTypes object from here.
 * @param {function} request ACtual request function
 * @param {boolean} isCacheable If the action is returning a cacheable resource, that should enter the
 * cache system.
 * @param {function} selector A selector for the cache-state for the resource
 */
@param {string} moduleId
@param {string} restAction Either of: LOAD | CREATE | UPDATE | DELETE.
You can also import restActionTypes object from here.
@param {function} request ACtual request function
@param {boolean} isCacheable If the action is returning a cacheable resource, that should enter the
cache system.
@param {function} selector A selector for the cache-state for the resource
@param { string } moduleId @param { string } restAction Either of : LOAD | CREATE | UPDATE | DELETE . You can also import restActionTypes object from here . @param { function } request ACtual request function @param { boolean } isCacheable If the action is returning a cacheable resource that should enter the cache system . @param { function } selector A selector for the cache - state for the resource
function createRestRequestAction(moduleId, restAction = restActionTypes.LOAD, request, isCacheable = false, selector = null) {
  invariant(_.has(restActionTypes, restAction.toUpperCase()), 
    'Expected restactionTypes to be either of: load, create, update, delete.')
  invariant(_.isString(moduleId), 'Expected moduleId to be a string')
  if(isCacheable){
    invariant( isFunction(selector), 'Expected cacheSelector to be a function')
    var metaCreator = () => { return { checkCache: true, cacheSelector: selector }}
  }
  const type = `${moduleId}_${restAction}`.toUpperCase()
  return createRequestAction(
    type, 
    request, 
    null, 
    isCacheable ? metaCreator : null
  )
}
function createRestRequestAction ( moduleId , restAction = restActionTypes . LOAD , request , isCacheable = false , selector = null ) { invariant ( _ . has ( restActionTypes , restAction . toUpperCase ( ) ) , 'Expected restactionTypes to be either of: load, create, update, delete.' ) invariant ( _ . isString ( moduleId ) , 'Expected moduleId to be a string' ) if ( isCacheable ) { invariant ( isFunction ( selector ) , 'Expected cacheSelector to be a function' ) var metaCreator = ( ) => { return { checkCache : true , cacheSelector : selector } } } const type = ` ${ moduleId } ${ restAction } ` . toUpperCase ( ) return createRequestAction ( type , request , null , isCacheable ? metaCreator : null ) }
@param {string} moduleId
 @param {string} restAction Either of: LOAD | CREATE | UPDATE | DELETE.
@param { string } moduleId @param { string } restAction Either of : LOAD | CREATE | UPDATE | DELETE .
// Check if the selector is a valid function // Prepend the module ID (i.e: USERS_LOAD)