Created
June 30, 2020 21:26
-
-
Save theboreddev/619e48d20a9c5c8d4c88540c7c28ba06 to your computer and use it in GitHub Desktop.
chain
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
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