Package-level declarations

Types

Link copied to clipboard
expect fun interface Consumer<T>
actual fun interface Consumer<T>
Link copied to clipboard
class Result<out T>

A discriminated union that encapsulates a successful outcome with a value of type T or a failure with a PubNubException.

Functions

Link copied to clipboard
inline fun <R, T> Result<T>.fold(onSuccess: (value: T) -> R, onFailure: (exception: Throwable) -> R): R

Returns the result of onSuccess for the encapsulated value if this instance represents success or the result of onFailure function for the encapsulated Throwable exception if it is failure.

Link copied to clipboard
inline fun <R, T : R> Result<T>.getOrDefault(defaultValue: R): R

Returns the encapsulated value if this instance represents success or the defaultValue if it is failure.

Link copied to clipboard
inline fun <R, T : R> Result<T>.getOrElse(onFailure: (exception: PubNubException) -> R): R

Returns the encapsulated value if this instance represents success or the result of onFailure function for the encapsulated PubNubException exception if it is failure.

Link copied to clipboard
fun <T> Result<T>.getOrThrow(): T

Returns the encapsulated value if this instance represents success or throws the encapsulated PubNubException if it is failure.

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

Returns the encapsulated result of the given transform function applied to the encapsulated value if this instance represents success or the original encapsulated Throwable exception if it is failure.

Link copied to clipboard
inline fun <R, T> Result<T>.mapCatching(transform: (value: T) -> R): Result<R>
Link copied to clipboard
inline fun <T, R> T.runCatching(block: T.() -> R): Result<R>
Link copied to clipboard