Skip to content

Instantly share code, notes, and snippets.

@wangjiegulu
Created December 31, 2015 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wangjiegulu/737ca3649fec354898c9 to your computer and use it in GitHub Desktop.
Save wangjiegulu/737ca3649fec354898c9 to your computer and use it in GitHub Desktop.
Dagger2: Component Dependencies
@Module
public class InteractorModule {
    @Provides
    public ILoginInfoInteractor providerILoginInfoInteractor() {
        return InteractorFactory.get(ILoginInfoInteractor.class);
    }
}

@Component(modules = InteractorModule.class)
public interface InteractorComponent {
    ILoginInfoInteractor loginInfoInteractor();
}

@Component(modules = {LoginPresenterModule.class}, dependencies = {InteractorComponent.class})
public interface LoginPresenterComponent extends PresenterComponent{
    void inject(LoginPresenter loginPresenter);
}

LoginPresenter:

@Inject
lateinit var loginInfoInteractor: Lazy<ILoginInfoInteractor>;

DaggerLoginPresenterComponent.builder()
                .loginPresenterModule(LoginPresenterModule())
                .interactorComponent(
                        DaggerInteractorComponent.builder().build()
                )
//                .interactorModule(InteractorModule())
                .build().inject(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment