Last active
March 5, 2018 09:47
-
-
Save sht5/229aea45a4f146e86244171e4b54c924 to your computer and use it in GitHub Desktop.
repetitive async actions
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 requestToGetCoins = async() => { | |
return (dispatch) => { | |
dispatch(requestToGetCoinsInProgress()); | |
try{ | |
const users = await httpService.getCoins(); | |
dispatch(requestToGetCoinsSuccess(users)); | |
} | |
catch(e){ | |
dispatch(requestToGetCoinsError(e)); | |
} | |
}; | |
}; | |
const requestToGetCoinsSuccess = (coins) => { | |
return { | |
type: types.REQUEST_TO_GET_COINS_USERS_SUCCESS, | |
coins | |
}; | |
}; | |
const requestToGetCoinsInProgress = () => { | |
return { | |
type: types.REQUEST_TO_GET_COINS_USERS_IN_PROGRESS | |
}; | |
}; | |
const requestToGetCoinsError = () => { | |
return { | |
type: types.REQUEST_TO_GET_COINS_ERROR | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment