public interface

Async

com.salesforce.android.service.common.utilities.control.Async<T>

Summary

Nested Classes
interface Async.CancellationHandler  
interface Async.CompletionHandler  
interface Async.ErrorHandler  
interface Async.Handler<T>  
interface Async.ResultHandler<T>  
Public Methods
abstract <S extends ResultHandler<? super T> & Async.ErrorHandler & Async.CompletionHandler> Async<T> addHandler(S handler)
Convenience method for adding a handler that is both a ResultHandler and an ErrorHandler.
abstract void cancel()
Cancel the operation.
abstract <S> Async<S> chain(Function<? super T, ? extends Async<? extends S>> mapFunction)
Creates a new Async that maps the result of this async to another async with a different type.
abstract boolean hasFailed()
Checks if the operation has encountered an error.
abstract boolean inProgress()
Checks whether this operation is still in progress.
abstract boolean isCancelled()
Check if the operation has been cancelled.
abstract boolean isComplete()
Checks if the operation has completed succesfully.
abstract <S> Async<S> map(Function<? super T, ? extends S> mapFunction)
Creates a new Async that maps the result of this async to a different type.
abstract Async<T> onCancelled(Async.CancellationHandler handler)
Adds a handler that will be invoked when the operation is cancelled.
abstract Async<T> onComplete(Async.CompletionHandler handler)
Adds a handler that will be invoked when the operation completes successfully.
abstract Async<T> onError(Async.ErrorHandler handler)
Adds a handler that will be invoked if the operation ends in an error.
abstract Async<T> onResult(ResultHandler<? super T> handler)
Adds a handler to receive a result from this operation.
abstract Async<T> pipe(ResultReceiver<? super T> receiver)
Pipe the output from this Async to the input for a ResultReceiver.
abstract Async<T> removeCancellationHandler(Async.CancellationHandler handler)
Removes a single cancellation handler.
abstract Async<T> removeCompletionHandler(Async.CompletionHandler handler)
Removes a single completion handler.
abstract Async<T> removeErrorHandler(Async.ErrorHandler handler)
Removes a single error handler.
abstract <S extends ResultHandler<? super T> & Async.ErrorHandler & Async.CompletionHandler> Async<T> removeHandler(S handler)
Convenience method for removing something as both a result and error handler at once.
abstract Async<T> removeResultHandler(ResultHandler<? super T> handler)
Removes a single consumer.

Public Methods

public abstract Async<T> addHandler (S handler)

Convenience method for adding a handler that is both a ResultHandler and an ErrorHandler. This call is the same as operation.onResult(handler).onError(handler).

Parameters
handler The handler to add.
Returns
  • This instance for fluent API calls.

public abstract void cancel ()

Cancel the operation. No handlers will be invoked after cancel is called.

public abstract Async<S> chain (Function<? super T, ? extends Async<? extends S>> mapFunction)

Creates a new Async that maps the result of this async to another async with a different type.

Parameters
mapFunction The function that maps the type
Returns
  • The mapped async.

public abstract boolean hasFailed ()

Checks if the operation has encountered an error.

Returns
  • True if the operation has failed.

public abstract boolean inProgress ()

Checks whether this operation is still in progress.

Returns
  • False if the operation has completed, has failed, or has been cancelled.

public abstract boolean isCancelled ()

Check if the operation has been cancelled.

Returns
  • True if the operation has been cancelled, false otherwise.

public abstract boolean isComplete ()

Checks if the operation has completed succesfully.

Returns
  • True if the operation is complete.

public abstract Async<S> map (Function<? super T, ? extends S> mapFunction)

Creates a new Async that maps the result of this async to a different type.

Parameters
mapFunction The function that maps the type.
Returns
  • The mapped Async.

public abstract Async<T> onCancelled (Async.CancellationHandler handler)

Adds a handler that will be invoked when the operation is cancelled.

public abstract Async<T> onComplete (Async.CompletionHandler handler)

Adds a handler that will be invoked when the operation completes successfully.

public abstract Async<T> onError (Async.ErrorHandler handler)

Adds a handler that will be invoked if the operation ends in an error. If the operation has already ended in an error the handler will be called synchronously with the error. If the operation is cancelled or completes successfully the handler will not be called. Otherwise, the handler will be called when the error is encountered.

Parameters
handler The handler to add.
Returns
  • This instance for fluent API calls.

public abstract Async<T> onResult (ResultHandler<? super T> handler)

Adds a handler to receive a result from this operation. If the operation is already complete the handler will be called synchronously with the result. If the operation is cancelled or ends in an error the handler will not be called. Otherwise, the handler will be called when the result is available.

Parameters
handler The handler to add.
Returns
  • This instance for fluent API calls.

public abstract Async<T> pipe (ResultReceiver<? super T> receiver)

Pipe the output from this Async to the input for a ResultReceiver. Any errors/results/completes that occur for this instance will be propagated to the passed ResultReceiver.

Parameters
receiver The ResultReceiver to which to pipe the results.
Returns
  • This instance.

public abstract Async<T> removeCancellationHandler (Async.CancellationHandler handler)

Removes a single cancellation handler. The operation will continue and other cancellation handlers may be notified.

public abstract Async<T> removeCompletionHandler (Async.CompletionHandler handler)

Removes a single completion handler. The operation will continue and other completion handlers may be notified.

public abstract Async<T> removeErrorHandler (Async.ErrorHandler handler)

Removes a single error handler. The operation will continue and other consumers may still receive a result.

Parameters
handler The ErrorHandler instance to remove.
Returns
  • This instance for fluent API calls.

public abstract Async<T> removeHandler (S handler)

Convenience method for removing something as both a result and error handler at once. This call is the same as operation.removeResultHandler(handler).removeErrorHandler(handler).

Parameters
handler The handler instance to remove.
Returns
  • This instance for fluent API calls.

public abstract Async<T> removeResultHandler (ResultHandler<? super T> handler)

Removes a single consumer. The operation will continue and other consumers may still receive a result.

Parameters
handler The ResultHandler instance to remove.
Returns
  • This instance for fluent API calls.