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

commonMain.kase.Result.kt Maven / Gradle / Ivy

There is a newer version: 3.0.13
Show newest version
@file:JsExport

package kase

import kotlinx.JsExport

/**
 * A Result is a state model that models outcome
 *
 * Conceptually, these are things that have already finished worked and
 * have a result/response which may either be a [Success] or [Failure].
 */
sealed interface Result : Possible, State, CanSucceed, CanFail {

    fun  map(transform: (D) -> R): Result

    fun catch(resolver: (Throwable) -> @UnsafeVariance D): Result

    fun andCatch(resolver: (Throwable) -> Result<@UnsafeVariance D>): Result

    fun onSuccess(callback: (D)->Unit) : Result

    fun onFailure(callback: (Throwable) -> Unit) : Result
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy