Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import promiseMiddleware from 'redux-promise-middleware'
import { createLogger } from 'redux-logger'
import {
createStore,
applyMiddleware,
compose,
} from 'redux'
import { loadingBarMiddleware } from 'react-redux-loading-bar'
import rootReducer from './reducer'
const createStoreWithMiddleware = compose(
applyMiddleware(
thunkMiddleware, // lets us dispatch() functions
promiseMiddleware(), // resolves promises
loadingBarMiddleware(), // manages loading bar
createLogger(), // log actions in console
),
)(createStore)
const store = createStoreWithMiddleware(rootReducer)
export default store
}
}
// }
// const state = JSON.parse(stateString)
// delete state.loadingBar // fixed loading bar always display issue
// return state
}
/*eslint-enable */
const store = createStore(
reducers,
getInitialState(),
compose(
applyMiddleware(
routerMiddleware(hashHistory),
loadingBarMiddleware(),
thunkMiddleware,
createLogger()
),
window.devToolsExtension ? window.devToolsExtension() : DevTools.instrument()
)
)
// store.dispatch(fetchArticleSummary())
// store.dispatch(fetchMusicList())
export default store
export default (history: Object, initialState: Object = {}): Store => {
// create the saga middleware
const sagaMiddleware = createSagaMiddleware();
const middlewares = [
thunk.withExtraArgument(axios),
routerMiddleware(history),
sagaMiddleware
];
const composeEnhancers =
(typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) ||
compose;
const enhancers = composeEnhancers(
applyMiddleware(
...middlewares,
loadingBarMiddleware({
promiseTypeSuffixes: ['REQUESTING', 'SUCCESS', 'FAILURE']
})
)
// Other store enhancers if any
);
const store = createStore(rootReducer, initialState, enhancers);
// then run the saga
sagaMiddleware.run(rootSaga);
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('./reducers', () => {
try {
const nextReducer = require('./reducers').default;
export default function createStore (history, client, data) {
// Sync dispatched route actions to the history
const reduxRouterMiddleware = syncHistory(history)
const middleware = [createMiddleware(client), reduxRouterMiddleware]
// Leave the __CLIENT__ check until below issue is resolved
// https://github.com/mironov/react-redux-loading-bar/issues/30
if (__CLIENT__) {
middleware.push(loadingBarMiddleware({
promiseTypeSuffixes: ['PENDING', 'SUCCESS', 'FAIL']
}))
}
let finalCreateStore
if (__DEVELOPMENT__ && __CLIENT__ && __DEVTOOLS__) {
const { persistState } = require('redux-devtools')
const DevTools = require('../containers/DevTools/DevTools')
finalCreateStore = compose(
applyMiddleware(...middleware),
window.devToolsExtension ? window.devToolsExtension() : DevTools.instrument(),
persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
)(_createStore)
} else {
finalCreateStore = applyMiddleware(...middleware)(_createStore)
}
export default function configureStore(initialState, history) {
const middlewares = [
sagaMiddleware,
routerMiddleware(history),
loadingBarMiddleware({ promiseTypeSuffixes: ['REQUEST', 'FULFILL'] }),
flashClearMiddleware,
]
const enhancers = [
applyMiddleware(...middlewares),
]
const composeEnhancers =
isDev && hasWindowObject && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
: compose
const store = createStore(
createReducer(),
initialState,
composeEnhancers(...enhancers)
advancedSearchPatient: {},
clinicalQuerySearch: {},
patientsSummaries: {},
isSidebarVisible: false,
profileAppPreferences: {},
patientsInfo: {},
requestError: {},
};
//create store and enhance with middleware
let store;
if (process.env.NODE_ENV === 'production') {
store = createStore(rootReducer, initialState, applyMiddleware(epicMiddleware, routerMiddlewareInstance, loadingBarMiddleware({ promiseTypeSuffixes: ['REQUEST', 'SUCCESS', 'FAILURE'] })));
} else {
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
store = createStore(rootReducer, initialState, composeEnhancers(applyMiddleware(epicMiddleware, routerMiddlewareInstance, loadingBarMiddleware({ promiseTypeSuffixes: ['REQUEST', 'SUCCESS', 'FAILURE'] }))));
}
//initialisation
store.dispatch(initialiseStart());
render(
//Provider allows us to receive data from store of our app (by connect function)
,
document.getElementById('app-root'),
);
const getMiddleware = () =>
applyMiddleware(
myRouterMiddleware,
sagaMiddleware,
thunk,
loadingBarMiddleware()
);
const configureMiddleware = () => {
const rootEpic = combineEpics(...epics);
const epicMiddleware = createEpicMiddleware({
dependencies: {
}
});
const loadingBarMid = loadingBarMiddleware({
promiseTypeSuffixes: ['REQUEST', 'SUCCESS', 'FAIL'],
});
const middleware = [
thunk,
epicMiddleware,
loadingBarMid
];
return { middleware, epicMiddleware, rootEpic };
}
import { loadingBarMiddleware } from "react-redux-loading-bar";
import { applyMiddleware, createStore } from "redux";
import { rootReducer } from "./actions";
export const store = createStore(
rootReducer,
applyMiddleware(
loadingBarMiddleware({
scope: "searchBar"
})
)
);
const configureMiddleware = (router) => {
const rootEpic = combineEpics(...epics);
const epicMiddleware = createEpicMiddleware({
dependencies: {
router: router
}
});
const loadingBarMid = loadingBarMiddleware({
promiseTypeSuffixes: ['REQUEST', 'SUCCESS', 'FAIL'],
});
const middleware = [
thunk,
epicMiddleware,
loadingBarMid
];
return { middleware, epicMiddleware, rootEpic };
}