PendingOperation
A reference to an ongoing asynchronous SDK operation, whose result is not yet known. It provides methods for checking whether the operation is complete, and whether it has succeeded. Additionally, it offers the ability to get its result either synchronously (blocking), or asynchronously via listeners.
If the operation succeeds, all completion and success listeners will be notified. The result will also be made available via the getResult()
method. If the operation fails, all completion and failure listeners will be notified, and the error will be made available via the getError()
method.
PendingOperation API
addOnCompleteListener
addOnCompleteListener
Adds an OnCompleteListener that will be invoked after the operation completes.
addOnSuccessListener
addOnSuccessListener
Adds an OnSuccessListener that will be invoked after the operation succeeds.
addOnFailureListener
addOnFailureListener
Adds an OnFailureListener that will be invoked after the operation fails.
isComplete
isComplete
Returns whether the operation has completed. If
true
, you can callisSuccessful()
to check whether it succeeded.
isSuccessful
isSuccessful
Returns whether the operation has succeeded. If this method returns
true
, you can callgetResult()
to obtain the result. Otherwise if it returnsfalse
, you can callgetError()
to obtain the error.
waitFor
waitFor
Waits till the operation is complete for the duration that is specified. Call {@link #isComplete()} after this method, to check whether the operation completed or if this method timed out.
@throws
InterruptedException
if thread is interrupted while waiting
waitTillCompletion
waitTillCompletion
Waits till the operation is complete.
throws
InterruptedException
if thread is interrupted while waiting.
getResult
getResult
Returns the result of the operation.
throws
InterruptedException
if thread is interrupted while waiting. throwsSdkException
if the operation has failed.
getResultOrNull
getResultOrNull
Returns the result of the operation if it completed successfully. Otherwise returns
null
.
getError
getError
Returns the error encountered during the operation.
throws
IllegalStateException
if the operation is not yet complete. throwsSdkException
if the PendingOperation has succeeded.
Last updated