Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { createStore, applyMiddleware } from 'redux';
import thunkMiddleware from 'redux-thunk';
import { composeWithDevTools } from 'redux-devtools-extension/developmentOnly';
import rootReducer from './reducers';
// Store setup
const middleware = applyMiddleware(thunkMiddleware);
const store = createStore(rootReducer, {}, composeWithDevTools(middleware));
export default store;
// const logger = createLogger({
// level: "log", // log, console, warn, error, info
// collapsed: true,
// diff: true,
// })
// Middleware.push(logger)
// }
const ealapi = new EALGISApiClient()
const composeEnhancers = composeWithDevTools({
// Specify name here, actionsBlacklist, actionsCreators and other options if needed
})
const store: Store = createStore(
reducers,
composeEnhancers(applyMiddleware(thunkMiddleware.withExtraArgument(ealapi), ...Middleware))
)
const history = syncHistoryWithStore(browserHistory as any, store)
ReactDOM.render(
{}}>
{getRoutes(store as any)}
,
document.getElementById("ealgis")
)
} from 'redux';
import rootReducer from './reducers/rootReducer';
import thunk from 'redux-thunk';
// Different middleware for production
let middleware = [thunk];
if (process.env.NODE_ENV !== 'production') {
const logger = require('redux-logger');
middleware = [
...middleware,
// logger(),
];
}
const customCreateStore = compose(
applyMiddleware(...middleware)
)(createStore);
// exports configureStore & initial state
export default function configureStore() {
return customCreateStore(rootReducer, {
sources: {},
});
}
const spy = sinon.spy()
function* handleActions(actions) {
spy(actions)
}
const combineLatest = createCombineLatest(effects)
function* saga() {
yield combineLatest(['type1', 'type2'], handleActions)
}
const sagaMiddleware = createSagaMiddleware(saga)
const store = createStore(
(state) => state,
applyMiddleware(sagaMiddleware)
)
describe('combineLatest', () => {
const action1 = { type: 'type1', some: 'payload' }
const action2 = { type: 'type2', some: 'payload' }
const action3 = { type: 'type2', other: 'payload' }
describe('when only one action type has been dispatched', () => {
it('should not yield saga yet', () => {
store.dispatch(action1)
expect(spy).not.to.be.called
})
})
describe('when all action types have been dispatched', () => {
it('should yield saga with all actions', () => {
import { createStore, applyMiddleware, combineReducers } from 'redux'
import createLogger from 'redux-logger'
import catchErrors from './middleware/catch_errors'
import * as reducers from './reducers'
const reducer = combineReducers({
routing: routeReducer,
...reducers})
const logger = createLogger()
let createStoreWithMiddleWare
if (process.env.NODE_ENV === 'development') {
createStoreWithMiddleWare = applyMiddleware(logger)(createStore)
} else {
createStoreWithMiddleWare = applyMiddleware(catchErrors)(createStore)
}
const store = createStoreWithMiddleWare(reducer)
syncReduxAndRouter(createBrowserHistory(), store)
export default store
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import './bootstrap';
import rootReducers from './state/rootReducers';
import Application from './Application';
if (document.getElementById('app')) {
const store = createStore(
rootReducers,
applyMiddleware(thunk)
);
render(
,
document.getElementById('app')
)
}
case CREATE_NEW_MESSAGE:
const newState = [ { date: date, postedBy, content: value } , ... state ]
return newState;
}
return state;
}
const combinedReducer = combineReducers({
userStatus: userStatusReducer,
messages: messageReducer,
apiCommunicationStatus: apiCommunicationStatusReducer
})
const store = createStore(
combinedReducer,
applyMiddleware(logger())
);
const render = ()=>{
const {messages, userStatus, apiCommunicationStatus} = store.getState();
document.getElementById("messages").innerHTML = messages
.sort((a,b)=>b.date - a.date)
.map(message=>(`
<div>
${message.postedBy} : ${message.content}
</div>`
)).join("");
document.forms.newMessage.newMessage.value = "";
document.forms.newMessage.fields.disabled = (userStatus === OFFLINE) || (apiCommunicationStatus === WAITING);
}
import 'whatwg-fetch'
import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'react-redux'
import { createStore, compose, applyMiddleware } from 'redux'
import thunk from 'redux-thunk'
import bindStoreToMenu from './bindStoreToMenu'
import NotebookReducer from './reducers'
import Notebook from './Notebook'
require('../scss/main.scss')
const store = compose(
applyMiddleware(thunk)
)(createStore)(NotebookReducer)
bindStoreToMenu(store)
render(
<div>
</div>
,
document.getElementById('kayero')
)
constructor(props) {
super(props);
this.store = createStore(reducer, createInitialState(), applyMiddleware(thunk));
}