Created
March 29, 2016 18:04
-
-
Save evidanary/98cccb03608fc902bfaba44121287b62 to your computer and use it in GitHub Desktop.
Demonstrating Promise.all
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
| //Async load items from a remote API | |
| loadItemsInStore(collection) { | |
| this.setState({ isFetchingItemsFromRemote: true}); | |
| let promises = []; | |
| for(let c of collection.values()) { | |
| promises.push(ItemService.getItems(c.id)); | |
| } | |
| let allPromises = Promise.all(promises); | |
| //Fulfill the Promise | |
| allPromises.then(() => { | |
| this.setState({ isFetchingItemsFromRemote: false}); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment