shlink-web-client/src/container/store.ts

21 lines
697 B
TypeScript
Raw Normal View History

import ReduxThunk from 'redux-thunk';
import { applyMiddleware, compose, createStore } from 'redux';
2020-08-22 08:47:19 +02:00
import { save, load, RLSOptions } from 'redux-localstorage-simple';
import reducers from '../reducers';
2020-08-22 08:47:19 +02:00
const isProduction = process.env.NODE_ENV !== 'production';
2020-08-29 13:51:53 +02:00
const composeEnhancers: Function = !isProduction && (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
2020-08-22 08:47:19 +02:00
const localStorageConfig: RLSOptions = {
states: [ 'settings', 'servers' ],
namespace: 'shlink',
namespaceSeparator: '.',
2020-05-03 20:16:21 +02:00
debounce: 300,
};
const store = createStore(reducers, load(localStorageConfig), composeEnhancers(
2020-08-22 08:10:31 +02:00
applyMiddleware(save(localStorageConfig), ReduxThunk),
));
export default store;