feat(wepback): Add app reducer hot reloading
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
import { Observable } from 'rx';
|
import { Observable } from 'rx';
|
||||||
|
import createDebugger from 'debug';
|
||||||
import { compose, createStore, applyMiddleware } from 'redux';
|
import { compose, createStore, applyMiddleware } from 'redux';
|
||||||
import { selectLocationState, connectRoutes } from 'redux-first-router';
|
import { selectLocationState, connectRoutes } from 'redux-first-router';
|
||||||
import { combineReducers } from 'berkeleys-redux-utils';
|
import { combineReducers } from 'berkeleys-redux-utils';
|
||||||
@ -14,6 +15,7 @@ import epics from './epics';
|
|||||||
import { onBeforeChange } from './utils/redux-first-router.js';
|
import { onBeforeChange } from './utils/redux-first-router.js';
|
||||||
import servicesCreator from '../utils/services-creator';
|
import servicesCreator from '../utils/services-creator';
|
||||||
|
|
||||||
|
const debug = createDebugger('fcc:app:createApp');
|
||||||
// createApp(settings: {
|
// createApp(settings: {
|
||||||
// history?: History,
|
// history?: History,
|
||||||
// defaultState?: Object|Void,
|
// defaultState?: Object|Void,
|
||||||
@ -84,6 +86,21 @@ export default function createApp({
|
|||||||
const store = createStore(reducer, defaultState, enhancer);
|
const store = createStore(reducer, defaultState, enhancer);
|
||||||
const location = selectLocationState(store.getState());
|
const location = selectLocationState(store.getState());
|
||||||
|
|
||||||
|
// note(berks): should get stripped in production client by webpack
|
||||||
|
// We need to find a way to hoist to top level in production node env
|
||||||
|
// babel plugin, maybe? After a quick search I couldn't find one
|
||||||
|
if (process.env.NODE_ENV === 'development') {
|
||||||
|
if (module.hot) {
|
||||||
|
module.hot.accept('./reducer.js', () => {
|
||||||
|
debug('hot reloading reducers');
|
||||||
|
store.replaceReducer(combineReducers(
|
||||||
|
require('./reducer.js').default,
|
||||||
|
panesReducer,
|
||||||
|
routesReducer
|
||||||
|
));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
// ({
|
// ({
|
||||||
// redirect,
|
// redirect,
|
||||||
// props,
|
// props,
|
||||||
|
Reference in New Issue
Block a user