Created
December 20, 2017 18:48
-
-
Save krescruz/0649e00eb4c2b8df3b1c8693f940d321 to your computer and use it in GitHub Desktop.
Loading in action using chain promises whit Redux
This file contains hidden or 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
/* | |
* Status Loading | |
* Actions types | |
*/ | |
const activatedLoading = () => ({ | |
type: 'LOADING_ACTIVATED', | |
status: true | |
}) | |
const deactivatedLoading = () => ({ | |
type: 'LOADING_DEACTIVATED', | |
status: false | |
}) | |
/* | |
* GET data init action | |
*/ | |
export const initData = () => (dispatch) => { | |
dispatch(activatedLoading()) | |
return Promise.all([ | |
dispatch(getDataOne()), | |
dispatch(getDataTwo()), | |
dispatch(getDataThree()) | |
]).then(() => { | |
dispatch(deactivatedLoading()) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment