-
public final class ResultKt
-
-
Method Summary
Modifier and Type Method Description final static <T extends Any, R extends Any> Result<R>flatMap(Result<T> $self, Function1<T, Result<R>> transform)Returns the result of applying the given transform function to the value of this Result if it is Result.isSuccess, or propagates the failure if it is Result.isFailure. final static <T extends Any> Result<T>onTokenError(Result<T> $self, SuspendFunction2<StreamEndpointException, Integer, Result<T>> function)Invokes the given function if this Result is a failure and the error is a token error. -
-
Method Detail
-
flatMap
final static <T extends Any, R extends Any> Result<R> flatMap(Result<T> $self, Function1<T, Result<R>> transform)
Returns the result of applying the given transform function to the value of this Result if it is Result.isSuccess, or propagates the failure if it is Result.isFailure.
This is the "monadic bind" operation for Result — it allows chaining of operations where each step returns a Result, without nesting (avoids
Result<Result<R>>).- Parameters:
transform- A function to transform the success value into another Result.
-
onTokenError
final static <T extends Any> Result<T> onTokenError(Result<T> $self, SuspendFunction2<StreamEndpointException, Integer, Result<T>> function)
Invokes the given function if this Result is a failure and the error is a token error.
- Parameters:
function- A function to invoke if this Result is a failure and the error is a token error.
-
-
-
-