Call

interface Call<T : Any>

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.

Inheritors

Types

Link copied to clipboard
fun interface Callback<T : Any>
Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract suspend fun await(): Result<T>

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

Link copied to clipboard
abstract fun cancel()

Cancels the execution of the call.

Link copied to clipboard
open fun enqueue()
abstract fun enqueue(callback: Call.Callback<T>)

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

Link copied to clipboard
abstract fun execute(): Result<T>

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

Inherited functions

Link copied to clipboard
fun <T : Any> Call<T>.doOnResult(scope: CoroutineScope, function: suspend (Result<T>) -> Unit): Call<T>

Run the given function before running the Call.

Link copied to clipboard
fun <T : Any> Call<T>.doOnStart(scope: CoroutineScope, function: suspend () -> Unit): Call<T>

Run the given function before running the Call.

Link copied to clipboard
fun <T : Any> Call<T>.enqueue(onSuccess: (T) -> Unit = onSuccessStub, onError: (StreamError) -> Unit = onErrorStub)
Link copied to clipboard

Forces a regular call to be used instead of DistinctCall.

Link copied to clipboard
fun <T : Any> Call<T>.launch(scope: CoroutineScope)

Launches a call using coroutines scope.

Link copied to clipboard
fun <T : Any, K : Any> Call<T>.map(mapper: (T) -> K): Call<K>

Maps a Call type to a transformed Call.

Link copied to clipboard
fun <T : Any> Call<T>.onErrorReturn(scope: CoroutineScope, function: suspend (originalError: StreamError) -> Result<T>): ReturnOnErrorCall<T>

Wraps this Call into ReturnOnErrorCall to return an item specified by side effect function when it encounters an error.

Link copied to clipboard
fun <T : Any> Call<T>.retry(scope: CoroutineScope, retryPolicy: RetryPolicy): Call<T>

Wraps the original call with RetryCall wrapper. Allows to retry the original call based on RetryPolicy

Link copied to clipboard
fun <T : Any> Call<T>.share(scope: CoroutineScope, identifier: () -> Int): Call<T>

Shares the existing Call instance for the specified identifier. If no existing call found the new Call instance will be provided.

Link copied to clipboard
Link copied to clipboard
fun <T : Any> Call<T>.withPrecondition(scope: CoroutineScope, precondition: suspend () -> Result<Unit>): Call<T>

Run the Call if the given precondition is Result.Success.

Link copied to clipboard
fun <T : Any, K : Any> Call<T>.zipWith(call: Call<K>): Call<Pair<T, K>>

Zips a Call of T and a given call of K.