Skip to content

Instantly share code, notes, and snippets.

@markerikson
Created June 12, 2016 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markerikson/a890c9d8f43ceb8bb37f4a9a64b4b4b9 to your computer and use it in GitHub Desktop.
Save markerikson/a890c9d8f43ceb8bb37f4a9a64b4b4b9 to your computer and use it in GitHub Desktop.
Store Enhancer example
export default function applyMiddleware(...middlewares) {
return (createStore) => (reducer, preloadedState, enhancer) => {
// snip actual enhancer logic
return {
...store,
dispatch
}
}
}
const middlewares = [thunk, myMiddleware];
const middlewareEnhancer = applyMiddleware(...middlewares);
const enhancers = compose(middlewareEnhancer, someOtherEnhancer);
const store = createStore(reducer, preloadedState, enhancers);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment