persistCombineReducers.js.flow 690 B

12345678910111213141516171819202122232425
  1. // @flow
  2. import { combineReducers } from 'redux'
  3. import persistReducer from './persistReducer'
  4. import autoMergeLevel2 from './stateReconciler/autoMergeLevel2'
  5. import type { PersistConfig } from './types'
  6. type Reducers = {
  7. [key: string]: Function,
  8. }
  9. type Reducer = (state: Object, action: Object) => Object
  10. // combineReducers + persistReducer with stateReconciler defaulted to autoMergeLevel2
  11. export default function persistCombineReducers(
  12. config: PersistConfig,
  13. reducers: Reducers
  14. ): Reducer {
  15. config.stateReconciler =
  16. config.stateReconciler === undefined
  17. ? autoMergeLevel2
  18. : config.stateReconciler
  19. return persistReducer(config, combineReducers(reducers))
  20. }