'use strict'
import * as types from '../constants/action-types'
import isArray from 'lodash/isArray'
import mergeWith from 'lodash/mergeWith'
import get from 'lodash/get'

const _ = {
  isArray,
  mergeWith,
  get
}

const initialStates = {
  isFetching: false
}

function customizer(objValue, srcValue) {
  if (_.isArray(objValue)) {
    return objValue.concat(srcValue)
  }
}

export const author = (state = initialStates, action = {}) => {
  switch (action.type) {
    case types.FETCH_AUTHOR_COLLECTION_REQUEST:
      return Object.assign({}, state, {
        isFetching: true
      })
    case types.FETCH_AUTHOR_COLLECTION_SUCCESS:
      let addToStore = action
      addToStore.isFetching = false
      return _.mergeWith({}, state, addToStore, customizer)
    case types.FETCH_AUTHOR_COLLECTION_FAILURE:
      return Object.assign({}, state, {
        isFetching: false,
        error: action.error
      })
    default:
      return state
  }
}

@@ -6,16 +6,17 @@
 strict'%0A
+%0A
 import *
@@ -57,16 +57,46 @@
 n-types'
+%0A%0Aimport get from 'lodash/get'
 %0Aimport 
@@ -169,37 +169,8 @@
 ith'
-%0Aimport get from 'lodash/get'
 %0A%0Aco
@@ -273,46 +273,91 @@
 on c
-ustomizer(objValue, srcValue) %7B%0A  if (
+oncatIfIsArray(previousValue, toAddValue, key) %7B%0A  if (key==='collectIndexList' && 
 _.is
@@ -362,19 +362,24 @@
 isArray(
-obj
+previous
 Value)) 
@@ -395,11 +395,16 @@
 urn 
-obj
+previous
 Valu
@@ -416,11 +416,13 @@
 cat(
-src
+toAdd
 Valu
@@ -690,16 +690,25 @@
 UCCESS:%0A
+      //%0A
       le
@@ -710,25 +710,29 @@
    let a
-ddToStore
+ctionObjToAdd
  = actio
@@ -740,25 +740,29 @@
 %0A      a
-ddToStore
+ctionObjToAdd
 .isFetch
@@ -814,29 +814,38 @@
 e, a
-ddToStore, customizer
+ctionObjToAdd, concatIfIsArray
 )%0A  

Change funciton naming