Future

interface Future<V, E>

The output of an asynchronous operation.

When the operation completes, it may return an error.

Inheritors

Properties

Link copied to clipboard
abstract val thread: ThreadRef

Functions

Link copied to clipboard
open suspend fun await(): V

Wait for the Future to complete using Kotlin Coroutines, and throw a VoiceException if the operation failed.

Link copied to clipboard
open suspend fun awaitNoThrow(): Result<V, E>

Wait for the Future to complete using Kotlin Coroutines. Will return errors rather than throwing an exception.

Link copied to clipboard
open fun <V2> chain(action: (V) -> Future<V2, E>): Future<V2, E>

When this Future completes, run another async operation.

Link copied to clipboard
open fun logError(tag: String, description: String): Future<V, E>

If this operation fails, log an error.

Link copied to clipboard
open fun <V2> map(filter: (V) -> V2): Future<V2, E>

If the Future returns successfully, transform the result to another type.

Link copied to clipboard
open fun <E2> mapError(filter: (E) -> E2): Future<V, E2>

If the Future returns an error, transform the error to another type.

Link copied to clipboard
abstract fun withCallback(callback: ResultCallback<V, E>): Future<V, E>

Give a callback when the Future completes.

Link copied to clipboard
open fun withErrorCallback(callback: Callback<E>): Future<V, E>

Give a callback if the Future returns an error.

Link copied to clipboard

Returns a new Future which times out after the specified duration.