mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-17 21:53:03 +05:30
#48: add accounts reducer and set up localStorage persistance
This commit is contained in:
parent
7dd58acede
commit
8601da786c
@ -33,6 +33,7 @@
|
||||
"react-router": "^2.0.0",
|
||||
"react-router-redux": "^3.0.0",
|
||||
"redux": "^3.0.4",
|
||||
"redux-localstorage": "^0.4.1",
|
||||
"redux-thunk": "^2.0.0",
|
||||
"webfontloader": "^1.6.26",
|
||||
"whatwg-fetch": "^1.0.0"
|
||||
|
@ -4,6 +4,7 @@ import { routeReducer } from 'react-router-redux';
|
||||
|
||||
import auth from 'components/auth/reducer';
|
||||
import user from 'components/user/reducer';
|
||||
import accounts from 'components/accounts/reducer';
|
||||
import i18n from 'components/i18n/reducer';
|
||||
import popup from 'components/ui/popup/reducer';
|
||||
import bsod from 'components/ui/bsod/reducer';
|
||||
@ -12,6 +13,7 @@ export default combineReducers({
|
||||
bsod,
|
||||
auth,
|
||||
user,
|
||||
accounts,
|
||||
i18n,
|
||||
popup,
|
||||
routing: routeReducer
|
||||
|
@ -4,6 +4,7 @@ import { createStore, applyMiddleware, compose } from 'redux';
|
||||
// а также дает возможность проверить какие-либо условия перед запуском экшена
|
||||
// или даже вообще его не запускать в зависимости от условий
|
||||
import thunk from 'redux-thunk';
|
||||
import persistState from 'redux-localstorage';
|
||||
import { syncHistory } from 'react-router-redux';
|
||||
import { browserHistory } from 'react-router';
|
||||
|
||||
@ -15,14 +16,17 @@ export default function storeFactory() {
|
||||
reduxRouterMiddleware,
|
||||
thunk
|
||||
);
|
||||
const persistStateEnhancer = persistState([
|
||||
'accounts'
|
||||
], {key: 'redux-storage'});
|
||||
|
||||
/* global process: false */
|
||||
let enhancer;
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
enhancer = compose(middlewares);
|
||||
enhancer = compose(middlewares, persistStateEnhancer);
|
||||
} else {
|
||||
const DevTools = require('containers/DevTools').default;
|
||||
enhancer = compose(middlewares, DevTools.instrument());
|
||||
enhancer = compose(middlewares, persistStateEnhancer, DevTools.instrument());
|
||||
}
|
||||
|
||||
const store = createStore(reducers, {}, enhancer);
|
||||
|
Loading…
Reference in New Issue
Block a user