Skip to content

Instantly share code, notes, and snippets.

@theboreddev
Created June 30, 2020 21:26
Show Gist options
  • Save theboreddev/619e48d20a9c5c8d4c88540c7c28ba06 to your computer and use it in GitHub Desktop.
Save theboreddev/619e48d20a9c5c8d4c88540c7c28ba06 to your computer and use it in GitHub Desktop.
chain
CompletableFuture<Void> chain = new CompletableFuture<>();
chain.thenComposeAsync(nil -> createUser())
.thenAcceptAsync(logNewUserId())
.thenComposeAsync(nil ->
registerAddress()
.thenAcceptBothAsync(registerPaymentDetails(), (address, paymentDetailsSuccess) -> {
System.out.println("Registered address was : " + address);
System.out.println("Registered payment details success : " + paymentDetailsSuccess);
})
)
.thenComposeAsync(nil -> sendEmail())
.thenAcceptAsync(result -> System.out.println("Email sent : " + result));
chain.complete(null);
Thread.sleep(2000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment