1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-10 10:28:56 +00:00
trezor-wallet/src/js/store/store.dev.js

58 lines
1.7 KiB
JavaScript
Raw Normal View History

2017-12-13 11:01:37 +00:00
/* @flow */
'use strict';
import { createStore, applyMiddleware, compose } from 'redux';
2018-02-20 09:30:36 +00:00
import { syncHistoryWithStore, routerMiddleware, push } from 'react-router-redux';
2017-12-13 11:01:37 +00:00
import thunk from 'redux-thunk';
2018-02-20 09:30:36 +00:00
// import createHistory from 'history/createBrowserHistory';
// import { useRouterHistory } from 'react-router';
2017-12-13 11:01:37 +00:00
import createHistory from 'history/createHashHistory';
import { createLogger } from 'redux-logger';
import reducers from '../reducers';
import services from '../services';
import { Middleware } from 'redux';
import { GenericStoreEnhancer } from 'redux';
2018-03-08 16:10:53 +00:00
import RavenMiddleware from 'redux-raven-middleware';
2017-12-13 11:01:37 +00:00
2018-02-20 09:30:36 +00:00
export const history = createHistory( { queryKey: false } );
2017-12-13 11:01:37 +00:00
const initialState: any = {};
const enhancers = [];
const middleware = [
thunk,
2018-03-08 16:10:53 +00:00
RavenMiddleware('https://497392c3ff6e46dc9e54eef123979378@sentry.io/294339'),
2017-12-13 11:01:37 +00:00
routerMiddleware(history)
];
const excludeLogger = (getState: any, action: any): boolean => {
//'@@router/LOCATION_CHANGE'
2018-02-20 09:30:36 +00:00
let excluded = ['LOG_TO_EXCLUDE'];
2017-12-13 11:01:37 +00:00
let pass = excluded.filter((act) => {
return action.type === act;
});
return pass.length === 0;
}
const logger: Middleware = createLogger({
level: 'info',
predicate: excludeLogger,
collapsed: true
});
if (process.env.NODE_ENV === 'development') {
const devToolsExtension: ?Function = window.devToolsExtension;
if (typeof devToolsExtension === 'function') {
enhancers.push(devToolsExtension());
}
}
const composedEnhancers: GenericStoreEnhancer = compose(
applyMiddleware(...middleware, logger, ...services),
...enhancers
);
export default createStore(
reducers,
initialState,
composedEnhancers
);