Skip to content

Instantly share code, notes, and snippets.

@Arfey
Created December 22, 2016 23:00
Show Gist options
  • Save Arfey/89c816ab2d0ec6a803ccce71560fbe8d to your computer and use it in GitHub Desktop.
Save Arfey/89c816ab2d0ec6a803ccce71560fbe8d to your computer and use it in GitHub Desktop.
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