Skip to content

Instantly share code, notes, and snippets.

@MaximeHeckel MaximeHeckel/getStore.js Secret
Last active Dec 28, 2018

Embed
What would you like to do?
import { createStore, applyMiddleware } from 'redux';
import appMiddleware from './middlewares';
import reducer from './reducer';
const history = { push: () => {}, location: { pathname: '/' } };
const getStore = (middlewares, initialState) => {
let actions = [];
const store = createStore(
reducer,
initialState,
applyMiddleware(
...appMiddleware(
{
history,
...middlewares,
},
false,
),
() => next => action => {
if (action.type) {
actions.push(action);
}
return next(action);
},
),
);
store.getActions = () => {
return actions;
};
return store;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.