Created
December 29, 2017 09:53
-
-
Save pokorson/d528860c95b7d48af348344906f056a4 to your computer and use it in GitHub Desktop.
Apply namespace for selectors, for multiple levels of re-exporting selectors.
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
export default function applyScopeToSelectors(selectors, stateKey) { | |
return Object.keys(selectors).reduce((res, val) => { | |
if (typeof selectors[val] === 'object') { | |
return { ...res, [val]: applyScopeToSelectors(selectors[val], stateKey) }; | |
} | |
return { ...res, [val]: state => selectors[val](state[stateKey]) }; | |
}, {}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment