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 createApplicationStore() {
const sagaMiddleware = createSagaMiddleware({
onError(error) {
if (get(console, ['error'])) {
// eslint-disable-next-line no-console
console.error(error);
}
bugsnagClient.notify(error);
},
});
const sagaEnhancer = applyMiddleware(sagaMiddleware);
const logicMiddleware = createLogicMiddleware(rootLogic);
const logicEnhancer = applyMiddleware(logicMiddleware);
const store = createStore(reducers, compose(sagaEnhancer, logicEnhancer));
sagaMiddleware.run(rootSaga);
return store;
}
console.error(err); // might be a render err
dispatch({
type: USERS_FETCH_REJECTED,
payload: err,
error: true
});
})
.then(() => done()); // call done when finished dispatching
}
});
const deps = { // injected dependencies for logic
httpClient: axios
};
const arrLogic = [usersFetchLogic];
const logicMiddleware = createLogicMiddleware(arrLogic, deps);
const store = createStore(reducer, initialState,
applyMiddleware(logicMiddleware));
const containerDiv = document.getElementById('container');
store.subscribe(() => {
const state = store.getState();
console.log('state fetchStatus:%o list:%o', state.fetchStatus, state.list);
containerDiv.innerHTML += formatStateForHTML(state);
});
function formatStateForHTML(state) {
return (
`<div>
<div>State at: ${Date.now()}</div>
<div>fetchStatus: ${state.fetchStatus}</div>
<ul></ul></div>
import rootReducer from '../reducers';
import rootActions from '../actions';
import logic from '../logics';
import api from '../../db';
const history = createHashHistory();
const deps = {
// injected dependencies for logic
Db: api.Db
};
const logicMiddleware = createLogicMiddleware(logic, deps);
const configureStore = initialState => {
// Redux Configuration
const middleware = [];
const enhancers = [];
// Thunk Middleware
middleware.push(logicMiddleware);
// Logging Middleware
const logger = createLogger({
level: 'info',
collapsed: true
});
// Skip redux logs in console during the tests
import logic from './rootLogic';
import { ajax } from 'rxjs/ajax';
// selectively just getting ajax and map from rxjs to keep size smaller
// be sure to add everything you need in your logic
// import 'rxjs/Observable';
// import 'rxjs/add/operator/catch';
// import 'rxjs/add/operator/map';
// import { ajax } from 'rxjs/observable/dom/ajax';
const deps = { // injected dependencies for logic
httpClient: ajax.getJSON // RxJS ajax
};
const logicMiddleware = createLogicMiddleware(logic, deps);
const middleware = applyMiddleware(
logicMiddleware
);
// using compose to allow for applyMiddleware, just add it in
const enhancer = (typeof devToolsExtension !== 'undefined') ?
compose(
middleware,
devToolsExtension()
) :
middleware;
export default function configureStore() {
const store = createStore(rootReducer, enhancer);
export default function(history) {
const middleware = applyMiddleware(routerMiddleware(history), createLogicMiddleware(logic))
return createStore(connectRouter(history)(reducer), composeEnhancers(middleware))
}
import { createLogicMiddleware } from 'redux-logic';
const logicsCtx = require.context('fm3/logic', false, /Logic\.[tj]s$/);
const logics = []
.concat(
...logicsCtx
.keys()
.sort()
.map(k => logicsCtx(k).default),
)
.filter(m => m);
export const logicMiddleware = createLogicMiddleware(logics);
export default function configureStore(initialState) {
const deps = {};
const logicMiddleware = createLogicMiddleware(logics, deps);
return createStore(
reducer,
initialState,
applyMiddleware(
logicMiddleware, logger()
)
);
};
export default function setupStore(history) {
const middleware = [
routerMiddleware(history),
createLogicMiddleware(logics),
createTracker(),
];
if (process.env.NODE_ENV === 'development') {
const { composeWithDevTools } = require('redux-devtools-extension');
const enhancer = composeWithDevTools(applyMiddleware(...middleware));
const store = createStore(reducer, enhancer);
if (module.hot) {
module.hot.accept('./controllers/reducers', () => {
const nextRootReducer = require('./controllers/reducers').default;
store.replaceReducer(nextRootReducer);
});
}
return store;
import React from 'react'
import ReactDOM from 'react-dom'
import { createStore, applyMiddleware } from 'redux'
import { Provider } from 'react-redux'
import { createLogicMiddleware } from 'redux-logic'
import './index.css'
import App from './App'
import reducer from './reducers'
import logic from './logics'
const logicMiddleware = createLogicMiddleware(logic)
const store = createStore(
reducer,
applyMiddleware(logicMiddleware)
)
ReactDOM.render(
,
document.getElementById('root')
)
export default function(history) {
const middleware = applyMiddleware(
requestPromiseMiddleware,
routerMiddleware(history),
createLogicMiddleware(logics),
)
return createStore(connectRouter(history)(reducer), composeEnhancers(middleware))
}