Package 

Class ResultKt

    • Method Detail

      • onSuccess

         final static <T extends Any> Result<T> onSuccess(Result<T> $self, Function1<T, Unit> successSideEffect)

        Runs the successSideEffect lambda function if the Result contains a successful data payload.

        Parameters:
        successSideEffect - A lambda that receives the successful data payload.
      • onSuccessSuspend

         final static <T extends Any> Result<T> onSuccessSuspend(Result<T> $self, SuspendFunction1<T, Unit> successSideEffect)

        Runs the suspending successSideEffect lambda function if the Result contains a successful data payload.

        Parameters:
        successSideEffect - A suspending lambda that receives the successful data payload.
      • map

         final static <T extends Any, K extends Any> Result<K> map(Result<T> $self, Function1<T, K> mapper)

        Returns a transformed Result of applying the given mapper function if the Result contains a successful data payload. Returns an original Result if the Result contains an error payload.

        Parameters:
        mapper - A lambda for mapping Result of T to Result of K.
      • mapSuspend

         final static <T extends Any, K extends Any> Result<K> mapSuspend(Result<T> $self, SuspendFunction1<T, K> mapper)

        Returns a transformed Result of applying the given suspending mapper function if the Result contains a successful data payload. Returns an original Result if the Result contains an error payload.

        Parameters:
        mapper - A suspending lambda for mapping Result of T to Result of K.
      • recover

         final static <T extends Any> Result<T> recover(Result<T> $self, Function1<ChatError, T> errorMapper)

        Recovers the error payload by applying the given errorMapper function if the Result contains an error payload.

        Parameters:
        errorMapper - A lambda that receives ChatError and transforms it as a payload T.
      • recoverSuspend

         final static <T extends Any> Result<T> recoverSuspend(Result<T> $self, SuspendFunction1<ChatError, T> errorMapper)

        Recovers the error payload by applying the given suspending errorMapper function if the Result contains an error payload.

        Parameters:
        errorMapper - A suspending lambda that receives ChatError and transforms it as a payload T.
      • onError

         final static <T extends Any> Result<T> onError(Result<T> $self, Function1<ChatError, Unit> errorSideEffect)

        Runs the errorSideEffect lambda function if the Result contains an error payload.

        Parameters:
        errorSideEffect - A lambda that receives the ChatError payload.
      • flatMap

         final static <T extends Any, R extends Any> Result<R> flatMap(Result<T> $self, Function1<T, Result<R>> func)

        Returns a transformed Result from results of the func if the Result contains a successful data payload. Returns an original Result if the Result contains an error payload.

        Parameters:
        func - A lambda that returns Result of R.
      • toResult

         final static <T extends Any> Result<T> toResult(T $self)

        Returns a Result that contains an instance of T as a data payload.