public static class CoroutineScopeOwner.DefaultImpls
This interface gives your class ability to execute class UseCase and class FlowUseCase Coroutine use cases.
You may find handy to implement this interface in custom Presenters, ViewHolders etc.
It is your responsibility to cancel coroutineScope when when all running tasks should be stopped.
class UseCase,
class FlowUseCase,
coroutineScope| Modifier and Type | Method and Description |
|---|---|
static void |
defaultErrorHandler(CoroutineScopeOwner $this,
java.lang.Throwable exception)
This method is called when coroutine launched with
launchWithHandler throws an exception and
this exception isn't CancellationException. By default, it rethrows this exception. |
static <T> void |
execute(CoroutineScopeOwner $this,
UseCase<kotlin.Unit,T> $receiver,
kotlin.jvm.functions.Function1<? super app.futured.arkitekt.crusecases.CoroutineScopeOwner.UseCaseConfig.Builder<T>,kotlin.Unit> config)
Asynchronously executes use case and saves it's Deferred. By default all previous
pending executions are canceled, this can be changed by the
config.
This version is used for use cases without initial arguments. |
static <ARGS,T> void |
execute(CoroutineScopeOwner $this,
UseCase<ARGS,T> $receiver,
ARGS args,
kotlin.jvm.functions.Function1<? super app.futured.arkitekt.crusecases.CoroutineScopeOwner.UseCaseConfig.Builder<T>,kotlin.Unit> config)
|
static <T> java.lang.Object |
execute(CoroutineScopeOwner $this,
UseCase<kotlin.Unit,T> $receiver,
boolean cancelPrevious,
kotlin.coroutines.Continuation<? super app.futured.arkitekt.crusecases.Result<? extends T>> p)
Synchronously executes use case and saves it's Deferred. By default all previous
pending executions are canceled, this can be changed by the
cancelPrevious.
This version is used for use cases without initial arguments. |
static <ARGS,T> java.lang.Object |
execute(CoroutineScopeOwner $this,
UseCase<ARGS,T> $receiver,
ARGS args,
boolean cancelPrevious,
kotlin.coroutines.Continuation<? super app.futured.arkitekt.crusecases.Result<? extends T>> p)
Synchronously executes use case and saves it's Deferred. By default all previous
pending executions are canceled, this can be changed by the
cancelPrevious.
This version gets initial arguments by args. |
static <T> void |
execute(CoroutineScopeOwner $this,
FlowUseCase<kotlin.Unit,T> $receiver,
kotlin.jvm.functions.Function1<? super app.futured.arkitekt.crusecases.CoroutineScopeOwner.FlowUseCaseConfig.Builder<T>,kotlin.Unit> config) |
static <ARGS,T> void |
execute(CoroutineScopeOwner $this,
FlowUseCase<ARGS,T> $receiver,
ARGS args,
kotlin.jvm.functions.Function1<? super app.futured.arkitekt.crusecases.CoroutineScopeOwner.FlowUseCaseConfig.Builder<T>,kotlin.Unit> config)
|
static kotlinx.coroutines.CoroutineDispatcher |
getWorkerDispatcher(CoroutineScopeOwner $this)
Provides Dispatcher for background tasks. This may be overridden for testing purposes
|
static void |
launchWithHandler(CoroutineScopeOwner $this,
kotlin.jvm.functions.Function2<? super kotlinx.coroutines.CoroutineScope,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,? extends java.lang.Object> block)
Launch suspend
block in coroutineScope. Encapsulates this call with try catch block and when an exception is thrown
then it is logged in UseCaseErrorHandler.globalOnErrorLogger and handled by defaultErrorHandler. |
@NotNull public static kotlinx.coroutines.CoroutineDispatcher getWorkerDispatcher(CoroutineScopeOwner $this)
Provides Dispatcher for background tasks. This may be overridden for testing purposes
public static <T> void execute(CoroutineScopeOwner $this, @NotNull UseCase<kotlin.Unit,T> $receiver, @NotNull kotlin.jvm.functions.Function1<? super app.futured.arkitekt.crusecases.CoroutineScopeOwner.UseCaseConfig.Builder<T>,kotlin.Unit> config)
Asynchronously executes use case and saves it's Deferred. By default all previous
pending executions are canceled, this can be changed by the config.
This version is used for use cases without initial arguments.
$receiver - class CoroutineScopeOwner.UseCaseConfig used to process results of internalCoroutine and to set configuration options.config - class CoroutineScopeOwner.UseCaseConfig used to process results of internal
Coroutine and to set configuration options.configpublic static <ARGS,T> void execute(CoroutineScopeOwner $this, @NotNull UseCase<ARGS,T> $receiver, ARGS args, @NotNull kotlin.jvm.functions.Function1<? super app.futured.arkitekt.crusecases.CoroutineScopeOwner.UseCaseConfig.Builder<T>,kotlin.Unit> config)
Asynchronously executes use case and saves it's Deferred. By default all previous
pending executions are canceled, this can be changed by the config.
This version gets initial arguments by args.
$receiver - Arguments used for initial use case initialization.args - class CoroutineScopeOwner.UseCaseConfig used to process results of internalCoroutine and to set configuration options.config - class CoroutineScopeOwner.UseCaseConfig used to process results of internal
Coroutine and to set configuration options.config,
args@Nullable public static <T> java.lang.Object execute(CoroutineScopeOwner $this, @NotNull UseCase<kotlin.Unit,T> $receiver, boolean cancelPrevious, @NotNull kotlin.coroutines.Continuation<? super app.futured.arkitekt.crusecases.Result<? extends T>> p)
Synchronously executes use case and saves it's Deferred. By default all previous
pending executions are canceled, this can be changed by the cancelPrevious.
This version is used for use cases without initial arguments.
class Result that encapsulates either a successful result with class Success or a failed result with class ErrorcancelPrevious@Nullable public static <ARGS,T> java.lang.Object execute(CoroutineScopeOwner $this, @NotNull UseCase<ARGS,T> $receiver, ARGS args, boolean cancelPrevious, @NotNull kotlin.coroutines.Continuation<? super app.futured.arkitekt.crusecases.Result<? extends T>> p)
Synchronously executes use case and saves it's Deferred. By default all previous
pending executions are canceled, this can be changed by the cancelPrevious.
This version gets initial arguments by args.
$receiver - Arguments used for initial use case initialization.args - Arguments used for initial use case initialization.class Result that encapsulates either a successful result with class Success or a failed result with class ErrorcancelPrevious,
argspublic static <T> void execute(CoroutineScopeOwner $this, @NotNull FlowUseCase<kotlin.Unit,T> $receiver, @NotNull kotlin.jvm.functions.Function1<? super app.futured.arkitekt.crusecases.CoroutineScopeOwner.FlowUseCaseConfig.Builder<T>,kotlin.Unit> config)
public static <ARGS,T> void execute(CoroutineScopeOwner $this, @NotNull FlowUseCase<ARGS,T> $receiver, ARGS args, @NotNull kotlin.jvm.functions.Function1<? super app.futured.arkitekt.crusecases.CoroutineScopeOwner.FlowUseCaseConfig.Builder<T>,kotlin.Unit> config)
Asynchronously executes use case and consumes data from flow on UI thread.
By default all previous pending executions are canceled, this can be changed
by config. When suspend function in use case finishes, onComplete is called
on UI thread. This version is gets initial arguments by args.
$receiver - Arguments used for initial use case initialization.args - class CoroutineScopeOwner.FlowUseCaseConfig used to process results of internalFlow and to set configuration options.config - class CoroutineScopeOwner.FlowUseCaseConfig used to process results of internal
Flow and to set configuration options.config,
argspublic static void launchWithHandler(CoroutineScopeOwner $this, @NotNull kotlin.jvm.functions.Function2<? super kotlinx.coroutines.CoroutineScope,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,? extends java.lang.Object> block)
Launch suspend block in coroutineScope. Encapsulates this call with try catch block and when an exception is thrown
then it is logged in UseCaseErrorHandler.globalOnErrorLogger and handled by defaultErrorHandler.
If exception is CancellationException then defaultErrorHandler is not called and
UseCaseErrorHandler.globalOnErrorLogger is called only if the root cause of this exception is not
CancellationException (e.g. when Result.getOrCancel is used).
public static void defaultErrorHandler(CoroutineScopeOwner $this, @NotNull java.lang.Throwable exception)
This method is called when coroutine launched with launchWithHandler throws an exception and
this exception isn't CancellationException. By default, it rethrows this exception.
launchWithHandler