Package-level declarations

Functions

Link copied to clipboard
inline fun <L, R> AsyncResult<Either<L, R>>.bind(): AsyncResult<R>

Based on the either values inside of the AsyncResult, convert it to a Success value if the Either was Either.Right, and a Error value if the Either was Either.Left. It will store the Either.Left contents, if any, in the Error.metadata value.

@JvmName(name = "bindWithLeftThrowable")
inline fun <R> AsyncResult<Either<Throwable, R>>.bind(): AsyncResult<R>

Based on the either values (Throwable at the left side, R at the right side) inside of the AsyncResult, convert it to a Success value if the Either was Either.Right, and a Error value if the Either was Either.Left while also storing the Throwable in the error in the Error.throwable property.

Link copied to clipboard
inline fun <L, R> Either<L, R>.toAsyncResult(): AsyncResult<R>

Based on the either values inside of the Either, convert it to a Success value it is Either.Right, and a Error value it is Either.Left. It will store the Either.Left contents, if any, in the Error.metadata value.

Link copied to clipboard
inline suspend fun <R> Flow<AsyncResult<R>>.toEither(): Either<Error, R>

Converts the receiver AsyncResult to an Either. It will use the Error as the value on the left side of the Either and the Success as the value on the right side of the Either.

inline suspend fun <E, R> Flow<AsyncResult<R>>.toEither(errorTransform: (Error) -> E = { it.metadataOrNull<E>() ?: error( "Unexpected error type: $it. " + "Expected ${E::class.simpleName}. Provide your own errorTransform function to handle this case.", ) }): Either<E, R>

Converts the receiver AsyncResult to an Either. By default, it will try to use the error in the from the Error.metadata value. In case you want to specify your own error type, you can use the errorTransform function.