Skip to content

Instantly share code, notes, and snippets.

@talyssonoc
Last active May 16, 2019 13:49
Show Gist options
  • Save talyssonoc/9dfd487b4a2d121fd897b2903b8a6996 to your computer and use it in GitHub Desktop.
Save talyssonoc/9dfd487b4a2d121fd897b2903b8a6996 to your computer and use it in GitHub Desktop.
const loadProductsAction = ({ withSpinner }) => (dispatch, _, container) => {
if(withSpinner) {
dispatch(showSpinner());
}
container.loadProducts({
onSuccess: (products) => {
dispatch(receiveProducts(products));
if(withSpinner) {
dispatch(hideSpinner());
}
},
onError: (error) => {
dispatch(loadProductsError(error));
if(withSpinner) {
dispatch(hideSpinner());
}
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment