Skip to content

Instantly share code, notes, and snippets.

@ctoestreich
Last active June 17, 2016 15:01
Show Gist options
  • Save ctoestreich/8ffaad1ec01e10a5f1c96a8b76c363cb to your computer and use it in GitHub Desktop.
Save ctoestreich/8ffaad1ec01e10a5f1c96a8b76c363cb to your computer and use it in GitHub Desktop.
Grails Async Sample
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