lazyViewModels

inline fun <VM : ViewModel> ComponentActivity.lazyViewModels(qualifier: Any? = null, noinline extrasProducer: () -> CreationExtras? = null): Lazy<VM>

Returns a Lazy delegate to access the Activity's ViewModel provided by Koject

class TopActivity : ComponentActivity() {
private val viewModel: TopViewModel by lazyViewModels()
}

Parameters

qualifier

Qualifier for identification.

extrasProducer

Create the default extras that will be used to create the ViewModel.