Created
December 1, 2017 15:58
-
-
Save sfrdmn/8fa0edb79882f0fcc3154b46b331a24c to your computer and use it in GitHub Desktop.
mcr_post_06
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
const fetchFoodItems = createActionCreator( | |
{ | |
pending: FOOD_ITEMS_FETCH_PENDING, | |
complete: FOOD_ITEMS_FETCH_COMPLETE, | |
error: FOOD_ITEMS_FETCH_ERROR, | |
}, | |
() => () => foodService.fetchFoodItems() | |
) | |
const addFoodItem = createActionCreator( | |
{ | |
pending: FOOD_ITEMS_ADD_PENDING, | |
complete: FOOD_ITEMS_ADD_COMPLETE, | |
error: FOOD_ITEMS_ADD_ERROR, | |
}, | |
// Here's an example where we take advantage of the fact we are wrapping | |
// totally normal thunk creators by also dispatching within the wrapped thunk | |
item => dispatch => ( | |
foodService | |
.addFoodItem(item) | |
.then((result) => { | |
dispatch(recordAnalytics({ event: 'OMG_SOMEONES_USING_THE_APP' })) | |
return result | |
}) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment