injectViewModels

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

Deprecated

Renamed to lazyViewModel.

Replace with

this.lazyViewModels(qualifier, extrasProducer)

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

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

Parameters

qualifier

Qualifier for identification.

extrasProducer

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