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