tangleViewModel

inline fun <VM : ViewModel> ComponentActivity.tangleViewModel(): Lazy<VM>

Equivalent to the Androidx ktx by viewModels() delegate.

Return

lazy ViewModel instance of the specified type, injected by Tangle/Anvil/Dagger

Since

0.11.0

Samples

import androidx.activity.ComponentActivity
import androidx.lifecycle.ViewModel
import tangle.inject.test.utils.Sample
import tangle.viewmodel.VMInject
import tangle.viewmodel.activity.tangleViewModel
fun main() { 
   //sampleStart 
   class MyActivity : ComponentActivity() {

  val viewModel: MyViewModel by tangleViewModel()
} 
   //sampleEnd
}

Sources

Link copied to clipboard