Last active
May 3, 2019 11:58
-
-
Save AJamesPhillips/31859809c949b3807cfb9014a5b24460 to your computer and use it in GitHub Desktop.
Small function for combining redux 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
function wrap_selectors (selectors, state_path) { | |
const wrapped_selectors = {} | |
Object.keys(selectors).forEach(selector_key => { | |
wrappedSelectors[selectorKey] = (state, ...args) => selectors[selectorKey](state[statePath], ...args) | |
}) | |
return wrapped_selectors | |
} | |
export const selectors = { | |
...wrap_selectors(shared_datetime_selectors, "shared_datetime"), | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment