Dagger 2 Tutorial for Android: Advanced – Part 2 | raywenderlich.com

In this tutorial, you’ll learn how to implement advanced features of Dagger 2 by using subcomponents, custom scopes and multibinding.

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/7337181-dagger-2-tutorial-for-android-advanced-part-2

Hi, if I am using a MVVM architecture, can I pretty much substitute all the presenter stuff with view model stuff? It still seems to be working so is there anything fundamentally wrong with this approach?

For example, provideNewsListPresenter and provideNewsDetailPresenter were replaced with provideNewsListViewModel and provideNewsDetailViewModel. End result being that the view models get injected with the repository still and the view models themselves get injected into the fragments.

@massimocarli Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hi @rw_pham
Sure. The current implementation uses MPV but if you use MVVM you just need to inject the Repository into the ViewModel. In this case, as you said, you might also need to also inject the ViewModel into the UI component owner of the lifecycle.