Skip to content

Instantly share code, notes, and snippets.

@amcdnl
Last active May 30, 2018 00:37
Show Gist options
  • Save amcdnl/4053d789b8833066025ad459ff875d69 to your computer and use it in GitHub Desktop.
Save amcdnl/4053d789b8833066025ad459ff875d69 to your computer and use it in GitHub Desktop.
const reduxAdapter = (middleware) => {
return (state, action, next) => {
const storeAdapter = {
getState: () => {
return state;
}
};
const nextAdapter = (fn) => {
const result = next(state, fn);
result.getState = storeAdapter.getState;
return result;
};
action.type = action.constructor.type;
return middleware(storeAdapter)(nextAdapter)(action);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment