Skip to content

Instantly share code, notes, and snippets.

@toruticas
Created May 27, 2019 02:21
Show Gist options
  • Save toruticas/de883d3f6619ccb37b96893e53a86cee to your computer and use it in GitHub Desktop.
Save toruticas/de883d3f6619ccb37b96893e53a86cee to your computer and use it in GitHub Desktop.
Redux Architecture Example (creators)
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