Skip to content

Instantly share code, notes, and snippets.

@krescruz
Created December 20, 2017 18:48
Show Gist options
  • Save krescruz/0649e00eb4c2b8df3b1c8693f940d321 to your computer and use it in GitHub Desktop.
Save krescruz/0649e00eb4c2b8df3b1c8693f940d321 to your computer and use it in GitHub Desktop.
Loading in action using chain promises whit Redux
/*
* 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