public interface Promise<RESULT>
Promise interface is very similar to a Future, but it provides
callbacks for completion, failure, and cancellation| Modifier and Type | Interface and Description |
|---|---|
static interface |
Promise.OnCancelListener
Task cancellation callback
|
static interface |
Promise.OnCompleteListener<RESULT>
Task completion callback
|
static interface |
Promise.OnFailListener
Task failure callback
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
isCancelled()
Is the task cancelled?
|
boolean |
isDone()
Are we there yet?
|
boolean |
isFailed()
Did you keep your promise?
|
Promise<RESULT> |
onCancel(Promise.OnCancelListener listener)
Add an
Promise.OnCancelListener callback to be notified on cancellation |
Promise<RESULT> |
onComplete(Promise.OnCompleteListener<RESULT> listener)
Add an
Promise.OnCompleteListener callback to be notified of completion |
Promise<RESULT> |
onFail(Promise.OnFailListener listener)
Add an
Promise.OnFailListener callback to be notified on failure |
boolean |
succeeded()
Was the promise successfully completed?
|
Promise<RESULT> onComplete(Promise.OnCompleteListener<RESULT> listener)
Promise.OnCompleteListener callback to be notified of completionlistener - listener to notify on completionPromise<RESULT> onFail(Promise.OnFailListener listener)
Promise.OnFailListener callback to be notified on failurelistener - listener to notify on failure.Promise<RESULT> onCancel(Promise.OnCancelListener listener)
Promise.OnCancelListener callback to be notified on cancellationlistener - listener to notify on cancellationboolean isDone()
true if task has run to completion (including due to failure or cancellation), false otherwiseboolean succeeded()
true if task was able to successfully obtain a result, false otherwiseboolean isFailed()
true if task has failed, false otherwiseboolean isCancelled()
true if task has been cancelled, false otherwise