Task
A discriminated union that encapsulates a successful outcome with a value of type ResultT or a failure with an arbitrary Throwable ClientException.
Parameters
a CoroutineScope defaulted to Default can provide your own scope as well, ensure its testable by injecting the provider.
Constructors
Types
Properties
using the Task's instance, we can cancel and running coroutines of this Task's scope. alternatively we can use the Task's cancel fun @see Task.cancel
Using the Task's instance, we can call complete.invoke passing in a ResultT if job succeeded or preferred Throwable ClientException as a failure result
using the Task's instance, we can call failure.invoke passing in a preferred Throwable ClientException as a failure result
Number of tires to run the task , this will configured using TaskConfig.retry
Functions
Wait for the task to finish
cancels the current task's scope and invokes a cancelTask.
Wait for the task to finish it is a blocking call, if using it inside coroutine or suspended function use awaitOrNull instead
a task finished scope that is attachable to a task instance * task().onComplete {res, e -> // handle task completed } Use this scope to retrieve the end result of a task with a ResultT if succeed or ClientException if failed
Experimental callback to avoid adding switch threads logic, Also allow a chance to perform UI and background jobs after a task is done without dealing with multithreading
Experimental callback to avoid adding switch threads logic, Also allow a chance to perform UI and background jobs after a task is done without dealing with multithreading
Experimental callback to avoid letting switch threads, Also allow a chance to perform UI and background jobs after a task is done without dealing with multithreading