All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.outcome.Conditional.kt Maven / Gradle / Ivy

package opensavvy.state.outcome

import opensavvy.state.outcome.Outcome.Success

/**
 * Executes [block] if this outcome is [successful][Success].
 *
 * Otherwise, does nothing.
 */
inline fun  Outcome<*, Value>.onSuccess(block: (Value) -> Unit) {
	if (this is Success)
        block(this.value)
}

/**
 * Executes [block] if this outcome is a [failure][Failure].
 *
 * Otherwise, does nothing.
 */
inline fun  Outcome.onFailure(block: (Failure) -> Unit) {
	if (this is Outcome.Failure)
		block(this.failure)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy