Last active
June 17, 2016 15:01
-
-
Save ctoestreich/8ffaad1ec01e10a5f1c96a8b76c363cb to your computer and use it in GitHub Desktop.
Grails Async Sample
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
| package foo | |
| import grails.async.Promise | |
| // more imports | |
| import static grails.async.Promises.waitAll | |
| import static grails.async.Promises.task | |
| class ProductService { | |
| ProductDTO getProduct(String id){ | |
| Promise<List<Warranty>> promiseWarranties = task { doWarrantyCall(id) } | |
| Promise<List<Link>> promiseCopyLinks = task { doLinksCall(id) } | |
| Promise<List<Specification>> promiseSpecifications = task { doSpecificationsCall(id) } | |
| Promise<List<Inventory>> promiseInventory = task { doInventoryCall(id) } | |
| Promise<List<Promotion> promisePromotions = task { doPromitionCall(id) } | |
| waitAll([promiseWarranties, promiseCopyLinks, promiseSpecifications, promiseInventory, promisePromotions]) | |
| //do more work here | |
| return new ProductDTO(data: data) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment