commonMain.kase.Result.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kase-core Show documentation
Show all versions of kase-core Show documentation
A kotlin multiplatform library to present common UI states
@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
}