Open cherylchan02 opened 1 year ago
I believe thenCompose
is used if you want to compose two Futures, so the output of one becomes the input of the other. On the other hand, thenCombine
is used if you want to put together both the outputs of each Future.
e.g. bar(foo(a)) --> thenCompose, but bar(a) + foo(a) --> thenCombine
CMIIW!
thenCombine
is similar to thenApply
but uses a Bifunction instead. thenCompose
is similar to flatmap, thenApply
is map
agree with @sumhungyee. comparing it to map will make it easier to understand
Both of these methods are used to combine 2 completable futures asynchronously, but I'm not very sure what differentiates them and which method to use in what circumstance. Would appreciate if someone could explain this thanks!