CoroutineCall

class CoroutineCall<T : Any>(scope: CoroutineScope, suspendingTask: suspend CoroutineScope.() -> Result<T>) : Call<T>

Constructors

Link copied to clipboard
constructor(scope: CoroutineScope, suspendingTask: suspend CoroutineScope.() -> Result<T>)

Functions

Link copied to clipboard
open suspend override 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
open override fun cancel()

Cancels the execution of the call.

Link copied to clipboard
open override 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
open override 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
open fun enqueue()

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

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.