public CoroutineScopeOwner
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 | Interface and Description |
|---|---|
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. |
static class |
CoroutineScopeOwner.FlowUseCaseConfig<T>
Holds references to lambdas and some basic configuration
used to process results of Flow use case.
Use
class FlowUseCaseConfig.Builder to construct this object. |
static class |
CoroutineScopeOwner.UseCaseConfig<T>
Holds references to lambdas and some basic configuration
used to process results of Coroutine use case.
Use
class UseCaseConfig.Builder to construct this object. |
| Modifier and Type | Method and Description |
|---|---|
void |
defaultErrorHandler(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. |
<T> void |
execute(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. |
<ARGS,T> void |
execute(UseCase<ARGS,T> $receiver,
ARGS args,
kotlin.jvm.functions.Function1<? super app.futured.arkitekt.crusecases.CoroutineScopeOwner.UseCaseConfig.Builder<T>,kotlin.Unit> config)
|
<T> java.lang.Object |
execute(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. |
<ARGS,T> java.lang.Object |
execute(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. |
<T> void |
execute(FlowUseCase<kotlin.Unit,T> $receiver,
kotlin.jvm.functions.Function1<? super app.futured.arkitekt.crusecases.CoroutineScopeOwner.FlowUseCaseConfig.Builder<T>,kotlin.Unit> config) |
<ARGS,T> void |
execute(FlowUseCase<ARGS,T> $receiver,
ARGS args,
kotlin.jvm.functions.Function1<? super app.futured.arkitekt.crusecases.CoroutineScopeOwner.FlowUseCaseConfig.Builder<T>,kotlin.Unit> config)
|
kotlinx.coroutines.CoroutineScope |
getCoroutineScope()
CoroutineScope scope used to execute coroutine based use cases. It is your responsibility to cancel it when all running
tasks should be stopped
|
kotlinx.coroutines.CoroutineDispatcher |
getWorkerDispatcher()
Provides Dispatcher for background tasks. This may be overridden for testing purposes
|
void |
launchWithHandler(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 kotlinx.coroutines.CoroutineScope getCoroutineScope()
CoroutineScope scope used to execute coroutine based use cases. It is your responsibility to cancel it when all running tasks should be stopped
@NotNull kotlinx.coroutines.CoroutineDispatcher getWorkerDispatcher()
Provides Dispatcher for background tasks. This may be overridden for testing purposes
<T> void execute(@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.
config - class CoroutineScopeOwner.UseCaseConfig used to process results of internalCoroutine and to set configuration options.config<ARGS,T> void execute(@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.
args - Arguments used for initial use case initialization.config - class CoroutineScopeOwner.UseCaseConfig used to process results of internalCoroutine and to set configuration options.config,
args@Nullable
<T> java.lang.Object execute(@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
<ARGS,T> java.lang.Object execute(@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.
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,
args<T> void execute(@NotNull
FlowUseCase<kotlin.Unit,T> $receiver,
@NotNull
kotlin.jvm.functions.Function1<? super app.futured.arkitekt.crusecases.CoroutineScopeOwner.FlowUseCaseConfig.Builder<T>,kotlin.Unit> config)
<ARGS,T> void execute(@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.
args - Arguments used for initial use case initialization.config - class CoroutineScopeOwner.FlowUseCaseConfig used to process results of internalFlow and to set configuration options.config,
argsvoid launchWithHandler(@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).
void defaultErrorHandler(@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