Skip to content

Instantly share code, notes, and snippets.

@rocketpages
Created December 25, 2016 04:56
Show Gist options
  • Save rocketpages/9980d632b45e08484f33667ef59728ae to your computer and use it in GitHub Desktop.
Save rocketpages/9980d632b45e08484f33667ef59728ae to your computer and use it in GitHub Desktop.
Async Shopping Cart Example
public CompletionStage<Result> index() {
Form<CheckoutForm> checkoutForm = formFactory.form(CheckoutForm.class);
CompletionStage<Cart> cartFuture = CompletableFuture.supplyAsync(() -> cartService.getCartForUser(), ec.current());
return cartFuture.thenApply(cart -> ok(index.render(cart, checkoutForm)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment