BaseCrViewModel

abstract class BaseCrViewModel<S : ViewState> : BaseViewModel<S> , CoroutineScopeOwner

Base ViewModel class prepared for providing data to UI through LiveData and obtaining data from Stores (Repositories) by executing Coroutine based use cases like UseCase and FlowUseCase.

Constructors

BaseCrViewModel
Link copied to clipboard
fun BaseCrViewModel()

Functions

clear
Link copied to clipboard
fun clear()
defaultErrorHandler
Link copied to clipboard
open fun defaultErrorHandler(exception: Throwable)
This method is called when coroutine launched with launchWithHandler throws an exception and this exception isn't CancellationException.
equals
Link copied to clipboard
open operator fun equals(other: Any?): Boolean
execute
Link copied to clipboard
open fun <T> FlowUseCase<Unit, T>.execute(config: CoroutineScopeOwner.FlowUseCaseConfig.Builder<T>.() -> Unit)
open suspend fun <T> UseCase<Unit, T>.execute(cancelPrevious: Boolean = true): Result<T>
Synchronously executes use case and saves it's Deferred.
open fun <T> UseCase<Unit, T>.execute(config: CoroutineScopeOwner.UseCaseConfig.Builder<T>.() -> Unit)
Asynchronously executes use case and saves it's Deferred.
open fun <ARGS, T> FlowUseCase<ARGS, T>.execute(args: ARGS, config: CoroutineScopeOwner.FlowUseCaseConfig.Builder<T>.() -> Unit)
Asynchronously executes use case and consumes data from flow on UI thread.
open suspend fun <ARGS, T> UseCase<ARGS, T>.execute(args: ARGS, cancelPrevious: Boolean = true): Result<T>
Synchronously executes use case and saves it's Deferred.
open fun <ARGS, T> UseCase<ARGS, T>.execute(args: ARGS, config: CoroutineScopeOwner.UseCaseConfig.Builder<T>.() -> Unit)
Asynchronously executes use case and saves it's Deferred.
getTag
Link copied to clipboard
open fun <T : Any> getTag(p0: String): T
getWorkerDispatcher
Link copied to clipboard
open fun getWorkerDispatcher(): CoroutineDispatcher
Provides Dispatcher for background tasks.
hashCode
Link copied to clipboard
open fun hashCode(): Int
launchWithHandler
Link copied to clipboard
open fun launchWithHandler(block: suspend CoroutineScope.() -> Unit)
Launch suspend block in coroutineScope.
observeEvent
Link copied to clipboard
fun observeEvent(lifecycleOwner: LifecycleOwner, eventClass: KClass<out Event<S>>, observer: (Event<S>) -> Unit)
observeWithoutOwner
Link copied to clipboard
fun <T> LiveData<T>.observeWithoutOwner(callback: (T) -> Unit)
fun <T : Any> DefaultValueLiveData<T>.observeWithoutOwner(callback: (T) -> Unit)
fun <T : Any> DefaultValueMediatorLiveData<T>.observeWithoutOwner(callback: (T) -> Unit)
onStart
Link copied to clipboard
open fun onStart()
sendEvent
Link copied to clipboard
fun sendEvent(event: Event<S>)
setTagIfAbsent
Link copied to clipboard
open fun <T : Any> setTagIfAbsent(p0: String, p1: T): T
toString
Link copied to clipboard
open fun toString(): String

Properties

coroutineScope
Link copied to clipboard
open override val coroutineScope: CoroutineScope
CoroutineScope scope used to execute coroutine based use cases.
internalSavedStateHandle
Link copied to clipboard
var internalSavedStateHandle: SavedStateHandle?
requireSavedStateHandle
Link copied to clipboard
val requireSavedStateHandle: SavedStateHandle
viewState
Link copied to clipboard
abstract val viewState: S