Value

class Value<out T>(val value: T) : Event<T> (source)

A value event containing the given value.

Constructors

Link copied to clipboard
constructor(value: T)

Properties

Link copied to clipboard
val value: T

Functions

Link copied to clipboard
inline fun <T> Event<T>.errorOrNull(): Throwable?

Returns the encapsulated error if this Event is an Event.Error, otherwise returns null.

Link copied to clipboard
inline fun <T> Event<T>.errorOrThrow(): Throwable

Returns the encapsulated error if this Event is an Event.Error. Otherwise, throws a NoSuchElementException.

Link copied to clipboard
inline fun <T, R> Event<T>.flatMap(transform: (T) -> Event<R>): Event<R>

Returns the result of applying transform to this Event's value if this is a Event.Value. Otherwise, returns itself.

Link copied to clipboard
inline fun <T, R> Event<T>.map(transform: (T) -> R): Event<R>

When this Event is a Event.Value, return a Event.Value containing transformed value using transform. Otherwise, returns itself.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
inline fun <T> Event<T>.valueOrDefault(defaultValue: T): T?

Returns the encapsulated value if this Event is a Event.Value, otherwise returns defaultValue.

Link copied to clipboard
inline fun <T> Event<T>.valueOrElse(defaultValue: (Throwable?) -> T): T

Returns the encapsulated value if this Event is a Event.Value, otherwise returns the result of calling defaultValue function.

Link copied to clipboard
inline fun <T> Event<T>.valueOrNull(): T?

Returns the encapsulated value if this Event is a Event.Value, otherwise returns null.

Link copied to clipboard
inline fun <T> Event<T>.valueOrThrow(): T

Returns the encapsulated value if this Event is a Event.Value. If this is Event.Error, throws the encapsulated error. Otherwise, throws a NoSuchElementException.