Android ViewModel and FactoryProvider: good way to manage it with Dagger Multibindings

How use ViewModelFactory with Multibindings.

How it works, and what is the problem

The solution

  • the key: for example the class type of ViewModel MyViewModel::class
  • the value: the instance of ViewModel MyViewModel(repository, …)

Conclusions

Component with 3 ViewModels module

--

--

Staff Software Engineer Android @ Moneyfarm

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store