import { dangerouslyReplaceState , dangerouslyResetState } from '../../events/dangerous' ; import { combineReducers } from '../../helpers/combineReducers/combineReducers' ; import { ReducerFunction , ReducersMap } from '../createReducer/createReducer.h' ; private const dangerouslyReplaceStateType = dangerouslyReplaceState . getType ( ) ; private const dangerouslyResetStateType = dangerouslyResetState . getType ( ) ; private internal export function getRootReducer < State > ( reducers , initialState ) { const rootReducer = combineReducers < State > ( reducers ) ; return ( oldState , event ) => { let state = oldState ; if ( event . type === dangerouslyReplaceStateType ) { state = event . payload ; } if ( event . type === dangerouslyResetStateType ) { state = initialState ; } return rootReducer ( state , event ) ; } ; }