Package 

Interface Call


  • 
    public interface Call<T extends Object>
    
                        

    A pending operation waiting to be ran.

    There are several ways to run a Call:

    Running a Call more than once results in undefined behaviour.

    • Method Summary

      Modifier and Type Method Description
      abstract Result<T> execute() Executes the call synchronously, in a blocking way.
      abstract Unit enqueue(Call.Callback<T> callback) Executes the call asynchronously, on a background thread.
      Unit enqueue() Executes the call asynchronously, on a background thread.
      abstract Result<T> await() Awaits the result of this Call in a suspending way, asynchronously.
      abstract Unit cancel() Cancels the execution of the call.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • execute

        @WorkerThread() abstract Result<T> execute()

        Executes the call synchronously, in a blocking way. Only call this from a background thread.

      • enqueue

         abstract Unit enqueue(Call.Callback<T> callback)

        Executes the call asynchronously, on a background thread. Safe to call from the main thread.

        The callback will only be invoked in case the Call is not canceled, and always on the main thread.

      • enqueue

         Unit enqueue()

        Executes the call asynchronously, on a background thread. Safe to call from the main thread.

        To get notified of the result and handle errors, use enqueue(callback) instead.

      • await

         abstract Result<T> await()

        Awaits the result of this Call in a suspending way, asynchronously. Safe to call from any CoroutineContext.

        Does not throw exceptions. Any errors will be wrapped in the Result that's returned.

      • cancel

         abstract Unit cancel()

        Cancels the execution of the call.