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

Love podcasts or audiobooks? Learn on the go with our new app.