WrapperViewModel
The wrapper ViewModel used by buildOnViewModel.
Functions
Link copied to clipboard
Link copied to clipboard
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.
Link copied to clipboard
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.
Link copied to clipboard
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.
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: MutableStateFlow<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.
Link copied to clipboard