Skip to content
Advertisement

What Runnable to Pass when adding a listener to ApiFuture and ApiFuture?

I am saving a document to Google Cloud Firestore using Google Cloud Functions in Java language.

JavaScript

I want to add a listener to future here.

JavaScript

I am unable to find a Runnable which can serve the purpose here. I know I can call future.get() method to hold the execution and get the WriteResult object but I don’t want to do that.

Also, unable to understand how to add a listener to userDoc.get().

I have searched StackOverflow and Github already. Could not find anything helpful.

All the posts talk about ApiFuture.addListener() which is deprecated and is not available now.

Please find below my pom.xml

JavaScript

Already wasted 2 days. Please help.

Advertisement

Answer

According to the documentation, you can use ApiFutures.addCallBack:

JavaScript

https://googleapis.github.io/api-common-java/1.9.1/apidocs/

Example:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement