Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function configureStore(initialState = {}, sdk = null, analyticsHandlers = []) {
const middlewares = [thunk.withExtraArgument(sdk), analytics.createMiddleware(analyticsHandlers)];
// Enable Redux Devtools in client side dev mode.
const composeEnhancers =
config.dev && typeof window === 'object' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
: compose;
const enhancer = composeEnhancers(applyMiddleware(...middlewares));
const store = createStore(createReducer(), initialState, enhancer);
return store;
}
export default function configureStore(preloadedState = {}) {
const middlewares = [
// register request actions for dispatch
// so that it's accessible in respective thunk wrappers
thunk.withExtraArgument({ ...requestActions }),
serviceAlert()
];
// check if redux devtools extension compose available
// apply for development environment only
const withReduxDevtools =
isDev &&
typeof window !== 'undefined' &&
window.__REDUX_isDevTOOLS_EXTENSION_COMPOSE__;
// make compose enhancers
const composeEnhancers = withReduxDevtools
? window.__REDUX_isDevTOOLS_EXTENSION_COMPOSE__({
/* specify extension’s options, if any */
})
: compose;
export default function configureStore(initialState, helpersConfig) {
const helpers = createHelpers(helpersConfig);
const sagaMiddleware = createSagaMiddleware();
const epicMiddleware = createEpicMiddleware(epics);
const middlewares = [
epicMiddleware,
sagaMiddleware,
thunk.withExtraArgument(helpers)
// beforeLoggerMiddleware,
// afterLoggerMiddleware,
];
let enhancer;
if (__DEV__) {
middlewares.push(createLogger());
// https://github.com/zalmoxisus/redux-devtools-extension#redux-devtools-extension
let devToolsExtension = f => f;
if (process.env.BROWSER && window.devToolsExtension) {
devToolsExtension = window.devToolsExtension();
}
enhancer = compose(
export default () => {
const logger = {
log: (message: string, payload: Object) => null,
}
const loggerMiddleware = createLogger({
collapsed: true,
predicate: (getState, action) => !action.doNotLog,
})
const middlewares = [thunk.withExtraArgument({logger})]
if (process.env.NODE_ENV === 'development') {
middlewares.push(loggerMiddleware)
}
// When not running devtools, use regular compose
const composeEnhancers =
(window.__DEV__ && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose
const store = createStore(
rootReducer,
getInitialState(),
composeEnhancers(applyMiddleware(...middlewares)),
)
if (process.env.NODE_ENV === 'development') {
logger.log = (message: string, payload: Object) =>
export default (initialState: Object = {}) => {
const middlewares = [
thunk.withExtraArgument(axios),
];
const enhancers = [
applyMiddleware(...middlewares),
__DEV__ && typeof window === 'object' && typeof window.devToolsExtension !== 'undefined' ?
window.devToolsExtension() : f => f,
];
const store: Store = createStore(createReducer(), initialState, compose(...enhancers));
store.asyncReducers = {}; // Async reducer registry
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('./reducers', () => {
try {
export default function configureStore(history, preloadedState) {
const reduxRouterMiddleware = routerMiddleware(history);
const middlewares = [thunk.withExtraArgument(api), reduxRouterMiddleware];
const enhancers = [
applyMiddleware(...middlewares),
IS_DEV &&
typeof window === 'object' &&
typeof window.devToolsExtension !== 'undefined'
? window.devToolsExtension()
: f => f,
];
// Creating the store
const store = createStore(rootReducer, preloadedState, compose(...enhancers));
/* istanbul ignore next */
if (module.hot) {
module.hot.accept('./reducers', () => {
export default function init(app: App, userCollection?: string): Promise {
if (store) {
throw new Error('Cannot initialize store more than once.');
}
const firestore = firebase.firestore(app);
const auth = firebase.auth(app);
const thunkArgs = { auth, firestore };
const middleware = [thunk.withExtraArgument(thunkArgs), batchMiddleware];
if (process.env.NODE_ENV !== 'production') {
const createLogger = require('redux-logger').createLogger;
const logger = createLogger({ collapsed: true, diff: true });
middleware.push(logger);
}
store = createStore(reducers, applyMiddleware(...middleware));
if (process.env.NODE_ENV !== 'production') {
window.redux = store;
}
const select = initSelect(store);
const selectAuth = initSelectAuth(auth, userCollection);
const selectStorage = initSelectStorage(store);
/**
* 创建Store,整合Provider
* create by 2017-01-10
* @flow
*/
import thunk from 'redux-thunk';
import {createStore, applyMiddleware,compose} from 'redux';
import _middleware from "../middleware"
import rootReducer from '../reducers/Index';
const _thunk = [thunk.withExtraArgument()];
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(rootReducer, {}, composeEnhancers(
applyMiddleware(
..._middleware.concat(_thunk)
)
));
export default store;
export default (req) => {
const axiosInstance = axios.create({
baseURL: 'http://react-ssr-api.herokuapp.com',
headers: { cookie: req.get('cookie') || '' },
});
const store = createStore(
reducers,
{},
applyMiddleware(thunk.withExtraArgument(axiosInstance)),
);
return store;
}
export const createStore = (_api) => {
const sagaMiddleware = createSagaMiddleware();
const storeMiddleware = [
sagaMiddleware,
reduxMiddleware.promiseCatchAll,
thunkMiddleware.withExtraArgument(_api),
];
if (process.env.NODE_ENV !== 'test') {
storeMiddleware.push(reduxLogger);
}
const store = createReduxStore(
combineReducers(reducers),
applyMiddleware(...storeMiddleware)
);
sagaMiddleware.run(blockchains.sagas.root, _api);
sagaMiddleware.run(ledger.sagas.root, _api);
sagaMiddleware.run(addressBook.sagas.root, _api);
sagaMiddleware.run(txhistory.sagas.root, _api);
sagaMiddleware.run(tokens.sagas.root, _api);