Created
October 20, 2015 16:20
-
-
Save srph/2ad5aa47b55e275252c7 to your computer and use it in GitHub Desktop.
resolve wrapper for redux + react resolver
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 { resolve } from 'react-resolver'; | |
import store from 'app-store'; | |
/** | |
* A wrapper to fill in the first argument with a dummy string. | |
* This helps because we usually don't set it to a prop, but | |
* to a Reducer. | |
* | |
* Also gives us the `dispatch` of the Store (yepee) | |
* | |
* Without this util: | |
* import store from 'app-store/'; | |
* const dispatch = store.get().dispatch; | |
* @resolve('@_RESOLVED_DATA_@', (props) => dispatch(SomeAction())); | |
* | |
* With this util: | |
* import 'app-utils/resolver/resolver'; | |
* @resolve(dispatch => props => dispatch(someAction(props.location.query.id))) | |
* | |
* @see | |
* react-resolver resolve | |
*/ | |
export default function(promise) { | |
const dispatch = store.get().dispatch; | |
return resolve('@_RESOLVED_DATA_@', promise(dispatch)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment