Created
May 10, 2016 19:53
-
-
Save smashercosmo/b6b9a53d7b70a2b7aa63f447a1f9d34f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const injectMiddleware = (staticDeps, dynamicDeps) => ({ dispatch, getState }) => next => action => { | |
const deps = {...staticDeps}; | |
Object.keys(dynamicDeps).forEach(key => { | |
deps[key] = dynamicDeps[key](); | |
}); | |
return next(typeof action === 'function' | |
? action({ ...deps, dispatch, getState }) | |
: action | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment