Last active
March 29, 2019 15:16
-
-
Save iagodahlem/fb2a8ad37093c670788b890f74654bce to your computer and use it in GitHub Desktop.
Scalable Frontend - The State Layer - Don't depend on the return of actions (wrong way)
This file contains 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
// action | |
const loadProduct = (id) => (dispatch, _, container) => { | |
container.loadProduct({ | |
onSuccess: (product) => dispatch(loadProductSuccess(product)), | |
onError: (error) => dispatch(loadProductError(error)), | |
}) | |
} | |
// component | |
componentDidMount() { | |
const { productId, loadProduct, loadComments } = this.props | |
loadProduct(productId) | |
.then(() => loadComments(productId)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment