feat: add ApiFutures.catchingAsync #117
feat: add ApiFutures.catchingAsync #117
Conversation
I would like to use this in Firestore. I tried to match the existing signature that allows the callback to return '? extends V' but this does not seem to be possible (see transformAsync).
Codecov Report
@@ Coverage Diff @@
## master #117 +/- ##
============================================
+ Coverage 60.48% 60.93% +0.44%
- Complexity 147 148 +1
============================================
Files 14 14
Lines 615 622 +7
Branches 92 92
============================================
+ Hits 372 379 +7
Misses 217 217
Partials 26 26
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a one-pager on what this is, what it's supposed to do, and why you need it? Without context it's hard to review constructively. Thanks.
This exposes "Futures.catchingAsync", similar to the existing "catching", which exposes "Futures.catching". The difference is that it allows an ApiAsyncFunction in its callback. I am currently working on a PR that sits on top of this branch which can shed light on its usage. |
@@ -104,6 +104,26 @@ public void onSuccess(V v) { | |||
return new ListenableFutureToApiFuture<V>(catchingFuture); | |||
} | |||
|
|||
public static <V, X extends Throwable> ApiFuture<V> catchingAsync( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overal looks good to me, but can we mark this as @Beta
API just in case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@elharo Here is a PR that uses it googleapis/java-firestore@d6de6ce#diff-dc2367736d16b0b533729ca22cb69d50R169
|
@vam-google @elharo Is there anything else that needs to be done here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Add new ApiFuture.catchingAsync method mirroring ApiFuture.catching, except allowing for an ApiAsyncFunction to be passed instead of ApiFunction. I tried to match the existing signature that allows the callback to return '? extends V' but this does not seem to be possible (see transformAsync).
I would like to use this in Firestore. I tried to match the existing signature that allows the callback to return '? extends V' but this does not seem to be possible (see transformAsync).