Created
April 24, 2017 13:08
-
-
Save jklingsporn/ac1f479cff54fc12a0f1f46808b879ef to your computer and use it in GitHub Desktop.
This file contains 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
//fetch something from A to make a lookup on B | |
ADao adao = new ADao(); | |
CompletableFuture<A> aFutureLoaded = adao.findByIdAsync(123); | |
BDao bdao = new BDao(); | |
aFutureLoaded.thenCompose( | |
a->bdao.findBySomeAValueAsync(a.getSomeAValue()); | |
).whenComplete((bResult,ex)->{ | |
if(ex==null){ | |
//do something with the result | |
}else{ | |
//oops something went wrong | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment