Last active
March 28, 2016 15:48
-
-
Save theshock/9b8e50a0140bd1e2507b 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
// from | |
[UPDATE_ENTITY_EDITABLE_LOADING]: (state, { data: { entityId, editableFieldName }}) => ({ | |
items: state.items.map(item => item.Id === entityId | |
? { ...item, [`loading${editableFieldName}`]: true } | |
: item), | |
error: null | |
}) | |
// to | |
[UPDATE_ENTITY]: (state, { data: { filterItemCallback, field, value }}) => ({ | |
items: state.items.map(item => | |
filterItemCallback(item) | |
? { ...item, [field]: value } | |
: item), | |
error: null | |
}) | |
// or, maybe: | |
[UPDATE_ENTITY]: (state, { data: { searchParams, changes }}) => ({ | |
items: state.items.map(item => | |
_.isMatch(searchParams, item) // https://lodash.com/docs#isMatch | |
? { ...item, ...changes } | |
: item), | |
error: null | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment