-
public interface Result<T extends Object>Represents an asynchronous operation that can be loading, failed, or successful.
A Success must be unwrapped before its value can be used. Suspending APIs generally return their values directly and throw on failure; this type is used where callers must observe an operation across Compose recompositions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classResult.LoadingThe operation has not completed.
public final classResult.ErrorThe operation failed with throwable.
public final classResult.SuccessThe operation completed with value.
-
Method Summary
Modifier and Type Method Description <R extends Any> Result<R>andThen(Function1<T, Result<R>> onSuccess)Chains this result into another result, forwarding loading and error states unchanged. <U extends Any, R extends Any> Result<R>andThen(Result<U> $self, Function1<U, Result<R>> onSuccess)Compatibility extension for the former dispatch-receiver API. <R extends Any> Result<R>map(Function1<T, R> transform)Maps the successful value while forwarding loading and error states unchanged. <U extends Any, R extends Any> Result<R>zip(Result<U> other, Function2<T, U, R> combine)Combines two successful results while forwarding the first loading or error state. <U extends Any> Result<Pair<T, U>>zip(Result<U> other)Pairs two successful results while forwarding the first loading or error state. <A extends Any, B extends Any, R extends Any> Result<R>zip(Result<A> $self, Result<B> other, Function2<A, B, R> combine)Compatibility extension for the former dispatch-receiver API. <A extends Any, B extends Any> Result<Pair<A, B>>zip(Result<A> $self, Result<B> other)Compatibility extension for the former dispatch-receiver API. <U extends Any> Result<List<U>>sequence(Iterable<Result<U>> $self)Compatibility extension for the former dispatch-receiver API. -
-
Method Detail
-
andThen
<R extends Any> Result<R> andThen(Function1<T, Result<R>> onSuccess)
Chains this result into another result, forwarding loading and error states unchanged.
The success transform is composable so it can invoke result-producing
rememberAPIs.- Parameters:
onSuccess- Produces the next result from a successful value.
-
andThen
<U extends Any, R extends Any> Result<R> andThen(Result<U> $self, Function1<U, Result<R>> onSuccess)
Compatibility extension for the former dispatch-receiver API.
- Parameters:
onSuccess- Produces the next result from a successful value.
-
map
<R extends Any> Result<R> map(Function1<T, R> transform)
Maps the successful value while forwarding loading and error states unchanged.
- Parameters:
transform- Maps a successful value to another value.
-
zip
<U extends Any, R extends Any> Result<R> zip(Result<U> other, Function2<T, U, R> combine)
Combines two successful results while forwarding the first loading or error state.
- Parameters:
other- The other result to combine with.combine- Maps both successful values to the combined value.
-
zip
<U extends Any> Result<Pair<T, U>> zip(Result<U> other)
Pairs two successful results while forwarding the first loading or error state.
- Parameters:
other- The other result to pair with.
-
zip
<A extends Any, B extends Any, R extends Any> Result<R> zip(Result<A> $self, Result<B> other, Function2<A, B, R> combine)
Compatibility extension for the former dispatch-receiver API.
- Parameters:
other- The other result to combine with.combine- Maps both successful values to the combined value.
-
zip
<A extends Any, B extends Any> Result<Pair<A, B>> zip(Result<A> $self, Result<B> other)
Compatibility extension for the former dispatch-receiver API.
- Parameters:
other- The other result to pair with.
-
-
-
-