toothpick
toothpick copied to clipboard
ViewModel constructor injection
This library seems to be long time abandoned, but if one day you like I find yourself on a project that uses Toothpick and question how to perform a constructor injection of ViewModel without too much hassle have a look at the following Gist:
https://gist.github.com/volo-droid/54d4443c28ec92ecb0a0741d16d4c47c
It allows to inject ViewModel in a simpler way.
class MainFragment : Fragment() {
private val viewModel by viewModelOf(::MyViewModel)
private val sharedViewModel by activityViewModelOf(::MySharedViewModel)
// …
}