Created
May 27, 2019 02:21
-
-
Save toruticas/de883d3f6619ccb37b96893e53a86cee to your computer and use it in GitHub Desktop.
Redux Architecture Example (creators)
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
import { Map } from 'immutable'; | |
import { getInputValue, getCurrentIndex } from './selectors'; | |
import { | |
addItem as addItemAction, | |
changeInputValue, | |
} from './actions'; | |
export const addItem = () => (dispatch, getState) => { | |
const state = getState(); | |
const value = getInputValue(state); | |
const index = getCurrentIndex(state); | |
dispatch(changeInputValue('')); | |
dispatch(addItemAction(Map({ id: index, value }))); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment