Created
December 22, 2016 23:00
-
-
Save Arfey/89c816ab2d0ec6a803ccce71560fbe8d to your computer and use it in GitHub Desktop.
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
import Promise from 'bluebird'; | |
export default function fetchComponentsData(dispatch, components, query, params) { | |
const promises = components | |
.filter(current => current) | |
.map(current => { | |
const component = current.WrappedComponent ? current.WrappedComponent : current; | |
return component.fetchData | |
? component.fetchData(dispatch, params, query, params.prefix) | |
: null; | |
}); | |
return Promise.all(promises); | |
} | |
class Layout extends React.Component { | |
constructor(props) { | |
super(props); | |
this.handlerScroll = this.handlerScroll.bind(this); | |
this.loadCarts = this.props.loadCarts.bind(this); | |
} | |
static fetchData(dispatch, params = {}, query = {}, prefix=null) { | |
return Promise.all( | |
[ | |
dispatch(actionsSearch.loadCountry(params, query, prefix)), | |
dispatch(actionsItem.loadCarts(params, query, prefix)), | |
] | |
); | |
} | |
.... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment