(store, isValid)
| 5 | import createReducer from '../reducers'; |
| 6 | |
| 7 | export function injectReducerFactory(store, isValid) { |
| 8 | return function injectReducer(key, reducer) { |
| 9 | if (!isValid) checkStore(store); |
| 10 | |
| 11 | invariant( |
| 12 | isString(key) && !isEmpty(key) && isFunction(reducer), |
| 13 | '(app/utils...) injectReducer: Expected `reducer` to be a reducer function', |
| 14 | ); |
| 15 | |
| 16 | // Check `store.injectedReducers[key] === reducer` for hot reloading when a key is the same but a reducer is different |
| 17 | if ( |
| 18 | Reflect.has(store.injectedReducers, key) && |
| 19 | store.injectedReducers[key] === reducer |
| 20 | ) |
| 21 | return; |
| 22 | |
| 23 | store.injectedReducers[key] = reducer; // eslint-disable-line no-param-reassign |
| 24 | store.replaceReducer(createReducer(store.injectedReducers)); |
| 25 | }; |
| 26 | } |
| 27 | |
| 28 | export default function getInjectors(store) { |
| 29 | checkStore(store); |
no test coverage detected