Result

sealed interface Result<out T>

Represents the result of an operation - typically loading - that can be in a loading, error, or success state. This includes Rive file loading. The Success result must be unwrapped to the value, e.g. through Kotlin's when/is statements.

Inheritors

Types

Link copied to clipboard
data class Error(val throwable: Throwable) : Result<Nothing>
Link copied to clipboard
Link copied to clipboard
data class Success<T>(val value: T) : Result<T>

Functions

Link copied to clipboard
open fun <T, R> Result<T>.andThen(onSuccess: @Composable (T) -> Result<R>): Result<R>

Convenience to chain the result of one Result into another, forwarding loading and error states, and mapping the success to another Result.

Link copied to clipboard
open fun <T, R> Result<T>.andThen(onSuccess: @Composable (T) -> Result<R>): Result<R>

Convenience to chain the result of one Result into another, forwarding loading and error states, and mapping the success to another Result.

Link copied to clipboard
open fun <T> Iterable<Result<T>>.sequence(): Result<List<T>>

Convenience to join a list of Results into a Result of one List. Any loading or error states will become the final Result state.

Link copied to clipboard
open fun <A, B> Result<A>.zip(other: Result<B>): Result<Pair<A, B>>

Convenience to join two Results into one, forwarding loading and error states, and mapping the combination to a Pair.

open fun <A, B, R> Result<A>.zip(other: Result<B>, combine: (A, B) -> R): Result<R>

Convenience to join two Results into one, forwarding loading and error states, and mapping the combination to another Result.

Link copied to clipboard
open fun <A, B> Result<A>.zip(other: Result<B>): Result<Pair<A, B>>

Convenience to join two Results into one, forwarding loading and error states, and mapping the combination to a Pair.

open fun <A, B, R> Result<A>.zip(other: Result<B>, combine: (A, B) -> R): Result<R>

Convenience to join two Results into one, forwarding loading and error states, and mapping the combination to another Result.