android-components / mozilla.components.service.fxa / FxaResult

FxaResult

class FxaResult<T> (source)

FxaResult is a class that represents an asynchronous result.

Parameters

Types

OnExceptionListener

interface OnExceptionListener<V>

An interface used to deliver exceptions to listeners of a FxaResult

OnValueListener

interface OnValueListener<T, U>

An interface used to deliver values to listeners of a FxaResult

Constructors

<init>

FxaResult()

FxaResult is a class that represents an asynchronous result.

Functions

complete

fun complete(value: T): Unit

This completes the result with the specified value. IllegalStateException is thrown if the result is already complete.

completeExceptionally

fun completeExceptionally(exception: Exception): Unit

This completes the result with the specified Exception. IllegalStateException is thrown if the result is already complete.

then

fun <U> then(fn: (value: T) -> FxaResult<U>?): FxaResult<U>

Adds a value listener to be called when the FxaResult is completed with a value. Listeners will be invoked on the same thread in which the FxaResult was completed.

fun <U> then(vfn: (value: T) -> FxaResult<U>?, efn: (Exception) -> FxaResult<U>?): FxaResult<U>
fun <U> then(valueListener: OnValueListener<T, U>, exceptionListener: OnExceptionListener<U>?): FxaResult<U>

Adds listeners to be called when the FxaResult is completed either with a value or Exception. Listeners will be invoked on the same thread in which the FxaResult was completed.

whenComplete

fun whenComplete(fn: (value: T) -> Unit): Unit

Adds a value listener to be called when the FxaResult and the whole chain of then calls is completed with a value. Listeners will be invoked on the same thread in which the FxaResult was completed.

Companion Object Functions

fromException

fun <T> fromException(exception: Exception): FxaResult<T>

This constructs a result that is completed with the specified Exception. May not be null.

fromValue

fun <U> fromValue(value: U): FxaResult<U>

This constructs a result that is fulfilled with the specified value.