Skip to content

Success

data class Success<Value>(val value: Value) : Outcome<Nothing, Value> 

The latest known result of the operation was a success, available as value.

Constructors

Success

constructor(value: Value)

Properties

failure

failureOrNull

Returns Failure.failure, or null if this outcome is not a failure.

value

val value: Value

value

valueOrNull

Returns Success.value, or null if this outcome is not successful.

Functions

map

If this outcome is successful, replaces its value using transform.

If this outcome isn't successful, does nothing.

See also

  • mapFailure: Map the failure state instead of the success state.

mapFailure

If this outcome is failed, replaces its failure using transformFailure.

If this outcome isn't failed, does nothing.

See also

  • map: Map the success state instead of the failure state.

onFailure

inline fun <Failure> Outcome<Failure, *>.onFailure(block: (Failure) -> Unit)

Executes block if this outcome is a failure.

Otherwise, does nothing.

onSuccess

inline fun <Value> Outcome<*, Value>.onSuccess(block: (Value) -> Unit)

Executes block if this outcome is successful.

Otherwise, does nothing.

toEither

Converts an Outcome into a typed Either.

withProgress

Adds progress information to this outcome to make it a ProgressiveOutcome.