tangleViewModel

inline fun <VM : ViewModel> Fragment.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.fragment.app.Fragment
import androidx.lifecycle.ViewModel
import tangle.inject.test.utils.Sample
import tangle.viewmodel.VMInject
import tangle.viewmodel.fragment.tangleViewModel
fun main() { 
   //sampleStart 
   class MyFragment : Fragment() {

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

Sources

Link copied to clipboard