src/utils/compositionUtils.js
function buildGriddleReducerObject(reducerObjects) {
  let reducerMethodsWithoutHooks = [];
  let beforeHooks = [];
  let afterHooks = [];

  let beforeReduceAll = [];
  let afterReduceAll = [];


  if (reducerObjects.length > 0) {
    // remove the hooks and extend the object
    for(const key in reducerObjects) {
      const reducer = reducerObjects[key];
      reducerMethodsWithoutHooks.push(removeHooksFromObject(reducer));
      beforeHooks.push(getBeforeHooksFromObject(reducer));
      afterHooks.push(getAfterHooksFromObject(reducer));
      beforeReduceAll.push(getBeforeReduceHooksFromObject(reducer));
      afterReduceAll.push(getAfterReduceHooksFromObject(reducer));
    }
  }

  const composedBeforeHooks = composeReducerObjects(beforeHooks);
  const composedAfterHooks = composeReducerObjects(afterHooks);

  const composedBeforeReduceAll = composeReducerObjects(beforeReduceAll);
  const composedAfterReduceAll = composeReducerObjects(afterReduceAll);

  // combine the reducers without hooks
  const combinedReducer = extendArray(reducerMethodsWithoutHooks);

  const composed = composeReducerObjects([
    composedBeforeReduceAll,
    composedBeforeHooks,
    combinedReducer,
    composedAfterHooks,
    composedAfterReduceAll
  ]);

  return composed;
}
function buildGriddleReducerObject(reducerObjects) {
  let reducerMethodsWithoutHooks = [];
  let beforeHooks = [];
  let afterHooks = [];

  let beforeReduceAll = [];
  let afterReduceAll = [];


  if (reducerObjects.length > 0) {
    // remove the hooks and extend the object
    for(const key in reducerObjects) {
      const reducer = reducerObjects[key];
      reducerMethodsWithoutHooks.push(removeHooksFromObject(reducer));
      beforeHooks.push(getBeforeHooksFromObject(reducer));
      afterHooks.push(getAfterHooksFromObject(reducer));
      beforeReduceAll.push(getBeforeReduceHooksFromObject(reducer));
      afterReduceAll.push(getAfterReduceHooksFromObject(reducer));
    }
  }

  const composedBeforeHooks = composeReducerObjects(beforeHooks);
  const composedAfterHooks = composeReducerObjects(afterHooks);

  const composedBeforeReduceAll = composeReducerObjects(beforeReduceAll);
  const composedAfterReduceAll = composeReducerObjects(afterReduceAll);

  // combine the reducers without hooks
  const combinedReducer = extendArray(reducerMethodsWithoutHooks);

  const composed = composeReducerObjects([
    composedBeforeReduceAll,
    composedBeforeHooks,
    combinedReducer,
    composedAfterHooks,
    composedAfterReduceAll
  ]);

  return composed;
}
function buildGriddleReducerObject ( reducerObjects ) { let reducerMethodsWithoutHooks = [ ] ; let beforeHooks = [ ] ; let afterHooks = [ ] ; let beforeReduceAll = [ ] ; let afterReduceAll = [ ] ; if ( reducerObjects . length > 0 ) { // remove the hooks and extend the object for ( const key in reducerObjects ) { const reducer = reducerObjects [ key ] ; reducerMethodsWithoutHooks . push ( removeHooksFromObject ( reducer ) ) ; beforeHooks . push ( getBeforeHooksFromObject ( reducer ) ) ; afterHooks . push ( getAfterHooksFromObject ( reducer ) ) ; beforeReduceAll . push ( getBeforeReduceHooksFromObject ( reducer ) ) ; afterReduceAll . push ( getAfterReduceHooksFromObject ( reducer ) ) ; } } const composedBeforeHooks = composeReducerObjects ( beforeHooks ) ; const composedAfterHooks = composeReducerObjects ( afterHooks ) ; const composedBeforeReduceAll = composeReducerObjects ( beforeReduceAll ) ; const composedAfterReduceAll = composeReducerObjects ( afterReduceAll ) ; // combine the reducers without hooks const combinedReducer = extendArray ( reducerMethodsWithoutHooks ) ; const composed = composeReducerObjects ( [ composedBeforeReduceAll , composedBeforeHooks , combinedReducer , composedAfterHooks , composedAfterReduceAll ] ) ; return composed ; }
Builds a new reducer that composes hooks and extends standard reducers between reducerObjects
@param {Object <array>} reducers - An array of reducerObjects
Note: this used to be exported, but the same properties are available from buildGriddleReducer.
TODO: This method should be broken down a bit -- it's doing too much currently
Builds a new reducer that composes hooks and extends standard reducers between reducerObjects