This is a great question. The next frontier for using this ViewModel pattern with the AbstractSavedStateViewModelFactory, as you mention is injecting the ViewModel entirely.

AssistedInject seems to be a promising method of injecting the ViewModel with Dagger. AssistedInject is on my personal learning roadmap so stay tuned for more in the future.

Manuel Vivo has been publishing good content surrounding Dagger, and it seems like improvements to Dagger for Android are coming. I’d imagine a a simplified approach to injecting ViewModel’s to be a part of those updates.



Open Sourcer

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