Package-level declarations

Types

Link copied to clipboard
interface Callback<T, U>

Generic callback interface with a generic return types.

Link copied to clipboard

Generic contract for an executor of Runnable callbacks.

Link copied to clipboard
fun interface Cancellable

Represents a cancellable operation.

Link copied to clipboard
Link copied to clipboard
fun interface Disposable

Represents a disposable resource.

Link copied to clipboard

Provides utilities to convert language from one format to another.

Link copied to clipboard

CallbackExecutor bound to the main thread of the application.

Link copied to clipboard
sealed class Result<out SuccessType, out FailureType>

Class that represents the parse result which can be Success or Failure.

Link copied to clipboard
value class UniqueId(val value: Long = nextValue.incrementAndGet())

Thread safe, single process 64 bit unique id. Not to be used if unique multi-process id generation is required.

Functions

Link copied to clipboard
inline fun <V, F, V2, F2> Result<V, F>.bimap(successMapper: (V) -> V2, failureMapper: (F) -> F2): Result<V2, F2>

Maps success value or failure.

Link copied to clipboard
inline fun <V, F, V2> Result<V, F>.flatMap(mapper: (V) -> Result<V2, F>): Result<V2, F>

Maps success value to a new Result or passes failure.

Link copied to clipboard
inline fun <V, F, R> Result<V, F>.fold(ifSuccess: (V) -> R, ifFailure: (F) -> R): R

Folds success or failure into a final value.

Link copied to clipboard
inline fun <V, F> Result<V, F>.ifFailure(ifFailure: (F) -> Unit): Result<V, F>

Performs provided operation if Result is failure.

Link copied to clipboard
inline fun <V, F> Result<V, F>.ifSuccess(ifSuccess: (V) -> Unit): Result<V, F>

Performs provided operation if Result is success.

Link copied to clipboard
inline fun <V, F, V2> Result<V, F>.map(mapper: (V) -> V2): Result<V2, F>

Maps success value or passes failure.

Link copied to clipboard
inline fun <V, F, F2> Result<V, F>.mapFailure(mapper: (F) -> F2): Result<V, F2>

Maps failure or passes success value.

Link copied to clipboard
fun <L, R> Result<R, L>.toEither(): Either<L, R>

Converts Result to Either. Result.Failure will be converted to Either.Left and Result.Success will be converted to Either.Right.

Link copied to clipboard
inline fun <V, F> Result<V, F>.valueOr(handler: (F) -> V): V

Returns success value or uses handler to map failure to value.