UNPKG

@randy.tarampi/jsx

Version:

Some common JSX components for www.randytarampi.ca

22 lines (21 loc) 733 B
import { push } from "connected-react-router/immutable"; import { createAction } from "redux-actions"; import selectors from "../../data/selectors"; export var SWIPEABLE_CHANGE_INDEX = "SWIPEABLE_CHANGE_INDEX"; export var swipeableChangeIndexCreator = (index, indexLatest, meta) => (dispatch, getState) => { dispatch(swipeableChangeIndex({ index, indexLatest, meta })); var state = getState(); var routeForIndex = selectors.getRouteForIndex(state, index); var path = routeForIndex ? routeForIndex.path : null; if (path) { dispatch(push({ pathname: path.split(":")[0] })); } }; export var swipeableChangeIndex = createAction(SWIPEABLE_CHANGE_INDEX); export default swipeableChangeIndexCreator;