Skip to content

//reactivestate/com.ensody.reactivestate.android/WrapperViewModel

WrapperViewModel

[android]\ class WrapperViewModel(val stateFlowStore: StateFlowStore) : ViewModel

The wrapper ViewModel used by buildOnViewModel.

Constructors

WrapperViewModel [android]
constructor(stateFlowStore: StateFlowStore)

Properties

Name Summary
registry [android]
val registry: MutableMap<KClass<*>, Any>
stateFlowStore [android]
val stateFlowStore: StateFlowStore

Functions

Name Summary
addCloseable [android]
open fun addCloseable(closeable: AutoCloseable)
fun addCloseable(key: String, closeable: AutoCloseable)
autoRun [android]
fun ViewModel.autoRun(launcher: CoroutineLauncher = if (this is CoroutineLauncher) this else SimpleCoroutineLauncher(viewModelScope), onChange: AutoRunOnChangeCallback<Unit>? = null, observer: AutoRunCallback<Unit>): AutoRunner<Unit>
Watches observables for changes. Often useful to keep things in sync.
coAutoRun [android]
fun ViewModel.coAutoRun(launcher: CoroutineLauncher = if (this is CoroutineLauncher) this else SimpleCoroutineLauncher(viewModelScope), onChange: CoAutoRunOnChangeCallback<Unit>? = null, observer: CoAutoRunCallback<Unit>): CoAutoRunner<Unit>
Watches observables for changes. Often useful to keep things in sync.
derived [android]
fun <T> ViewModel.derived(launcher: CoroutineLauncher = if (this is CoroutineLauncher) this else SimpleCoroutineLauncher(viewModelScope), synchronous: Boolean = true, observer: AutoRunCallback<T>): StateFlow<T>
Creates a StateFlow that computes its value based on other StateFlows via an autoRun block.
[android]
fun <T> ViewModel.derived(initial: T, started: SharingStarted = SharingStarted.Eagerly, launcher: CoroutineLauncher = if (this is CoroutineLauncher) this else SimpleCoroutineLauncher(viewModelScope), flowTransformer: AutoRunFlowTransformer = { conflatedWorker(transform = it) }, dispatcher: CoroutineDispatcher = dispatchers.main, withLoading: MutableValueFlow<Int>? = if (this is CoroutineLauncher) launcher.loading else null, observer: CoAutoRunCallback<T>): StateFlow<T>
Creates a StateFlow that computes its value based on other StateFlows via a suspendable coAutoRun block.
getCloseable [android]
fun <T : AutoCloseable> getCloseable(key: String): T?