Package nl.elements.mobilization.interactor

Types

Interactor
Link copied to clipboard
abstract class Interactor<in P>
Base interactor class to be used for work without a specific result.
InvokeError
Link copied to clipboard
data class InvokeError(throwable: Throwable) : InvokeStatus
InvokeStarted
Link copied to clipboard
object InvokeStarted : InvokeStatus
InvokeStatus
Link copied to clipboard
sealed class InvokeStatus
InvokeSuccess
Link copied to clipboard
object InvokeSuccess : InvokeStatus
ResultInteractor
Link copied to clipboard
abstract class ResultInteractor<in P, R>
Interactor used to get explicit result from the work performedCode example:
viewModelScope.launch {
val result = getResult(params).first()
}
SubjectInteractor
Link copied to clipboard
abstract class SubjectInteractor<P : Any, T>
Performs background work and is observed separatelyExamples:
  • retrieving database queries

  • retrieving asynchronous tasks

Code example:
viewModelScope.launch() {
observeUser.observe().collect { // update state }
}

observeUser()
SuspendingWorkInteractor
Link copied to clipboard
abstract class SuspendingWorkInteractor<P : Any, T : Any> : SubjectInteractor<P, T>
Performs suspending workExamples:
  • can be used within async / launch blocks from the viewmodel

  • direct search

Code example:
viewModelScope.launch {
val job = launch {
search(Params(query))
}
job.join()
}

Functions

invoke
Link copied to clipboard
operator fun Interactor<Unit>.invoke(): Flow<InvokeStatus>
operator fun <T> ResultInteractor<Unit, T>.invoke(): Flow<T>
operator fun <T> SubjectInteractor<Unit, T>.invoke()