Class CallKt

  • All Implemented Interfaces:

    
    public final class CallKt
    
                        
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

    • Method Detail

      • launch

         final static <T extends Any> Unit launch(Call<T> $self, CoroutineScope scope)

        Launches a call using coroutines scope.

        Parameters:
        scope - CoroutineScope to launch this procedure.
      • map

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

        Maps a Call type to a transformed Call.

        Parameters:
        mapper - A lambda for mapping Call of T to Call of K.
      • doOnStart

         final static <T extends Any> Call<T> doOnStart(Call<T> $self, CoroutineScope scope, SuspendFunction0<Unit> function)

        Run the given function before running the Call.

        Parameters:
        scope - CoroutineScope to launch this procedure.
        function - A given lambda function to be executed.
      • doOnResult

         final static <T extends Any> Call<T> doOnResult(Call<T> $self, CoroutineScope scope, SuspendFunction1<Result<T>, Unit> function)

        Run the given function before running the Call.

        Parameters:
        scope - CoroutineScope to launch this procedure.
        function - A given lambda function to be executed.
      • withPrecondition

         final static <T extends Any> Call<T> withPrecondition(Call<T> $self, CoroutineScope scope, SuspendFunction0<Result<Unit>> precondition)

        Run the Call if the given precondition is Result.Success.

        Parameters:
        scope - CoroutineScope to launch this procedure.
        precondition - A given Result to decide to execute this Call.
      • onErrorReturn

         final static <T extends Any> ReturnOnErrorCall<T> onErrorReturn(Call<T> $self, CoroutineScope scope, SuspendFunction1<Error, Result<T>> function)

        Wraps this Call into ReturnOnErrorCall to return an item specified by side effect function when it encounters an error.

        Parameters:
        scope - Scope of coroutine in which to execute side effect function.
        function - Function that returns data in the case of error.
      • share

         final static <T extends Any> Call<T> share(Call<T> $self, CoroutineScope scope, Function0<Integer> identifier)

        Shares the existing Call instance for the specified identifier. If no existing call found the new Call instance will be provided.

      • enqueue

         final static <T extends Any> Unit enqueue(Call<T> $self, Function1<T, Unit> onSuccess, Function1<Error, Unit> onError)
      • retry

         final static <T extends Any> Call<T> retry(Call<T> $self, CoroutineScope scope, RetryPolicy retryPolicy)

        Wraps the original call with RetryCall wrapper. Allows to retry the original call based on RetryPolicy

        Parameters:
        scope - Coroutine scope where the call should be run.
        retryPolicy - A policy used for retrying the call.