Runs a continuation when a task completes successfully, forwarding along errors or cancellation.
(
final Continuation<TResult, TContinuationResult> continuation, Executor executor)
| 402 | * cancellation. |
| 403 | */ |
| 404 | public <TContinuationResult> Task<TContinuationResult> onSuccess( |
| 405 | final Continuation<TResult, TContinuationResult> continuation, Executor executor) { |
| 406 | return continueWithTask(new Continuation<TResult, Task<TContinuationResult>>() { |
| 407 | public Task<TContinuationResult> then(Task<TResult> task) { |
| 408 | if (task.isFaulted()) { |
| 409 | return Task.<TContinuationResult> forError(task.getError()); |
| 410 | } else if (task.isCancelled()) { |
| 411 | return Task.<TContinuationResult> cancelled(); |
| 412 | } else { |
| 413 | return task.continueWith(continuation); |
| 414 | } |
| 415 | } |
| 416 | }, executor); |
| 417 | } |
| 418 | |
| 419 | /** |
| 420 | * Runs a continuation when a task completes successfully, forwarding along errors or |