onViewModel

inline fun <T> onViewModel(viewModelStoreOwner: ViewModelStoreOwner = checkNotNull(LocalViewModelStoreOwner.current) { "No ViewModelStoreOwner was provided via LocalViewModelStoreOwner" }, key: String? = null, crossinline provider: ReactiveStateContext.() -> T): T

Creates an object living on a wrapper ViewModel. This allows for building more flexible (e.g. nestable) ViewModels.

The provider should instantiate the object directly.

See also

if you want to instantiate a multiplatform ViewModel directly.