How can we add a module to Subcomponent.Builder in version 2.10-rc2?
See original GitHub issueWith the new functionality, we can inject Activity and Fragment using a single AndroidInjection.inject(this)
call. But how can we pass a module to Subcomponent’s builder?
For example, Activity’s subcomponent has a module which needs this Activity in the constructor.
@ActivityScope
@Subcomponent(modules = SplashActivitySubcomponent.SplashActivityModule.class)
public interface SplashActivitySubcomponent extends AndroidInjector<SplashActivity> {
@Subcomponent.Builder
abstract class Builder extends AndroidInjector.Builder<SplashActivity> {
}
@Module
abstract class SplashActivityModule extends ActivityModule<SplashActivity> {
SplashActivityModule(SplashActivity activity) {
super(activity);
}
@ActivityScope
@Provides
SplashContract.View provideView() {
return activity;
}
@ActivityScope
@Provides
SplashContract.Presenter providePresenter(SplashPresenter presenter) {
return presenter;
}
}
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:7
Top Results From Across the Web
Component - javadoc.io
Subcomponents are declared by listing the class in the Module.subcomponents() attribute of one of the parent component's modules. This binds the Subcomponent.
Read more >dagger.BindsInstance Maven / Gradle / Ivy - Download JAR files
dagger.BindsInstance maven / gradle build tool code. The class is part of the package ➦ Group: com.google.dagger ➦ Artifact: dagger ➦ Version: 2.10-rc2....
Read more >Dagger Android Migration Guide - Medium
To do that, we need another module that will just hold all the Activity modules. This module will then be included in the...
Read more >Dagger 2 updates (specifically for Android) : r/androiddev - Reddit
Your "ActivityBindingModule" (the module that declares the Activity subcomponent builders) that is part of the ApplicationComponent can be swapped out in ...
Read more >dagger-2.10-rc2-javadoc.jar下载及Maven、Gradle引入代码,pom ...
MF allclasses-noframe.html constant-values.html dagger/package-use.html dagger/Module.html dagger/package-frame.html dagger/Component.Builder.html ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry to tag on this issue, I am currently doing something else to achieve the same effect.
Is it a bad idea?
If I should post on SO or create anew issue just tell me.
@AntonyGolovin I’d suggest you look at the linked issue that @JakeWharton mentioned.
@JonathanMerritt - that does work, but it’s unnecessary. the
seedInstance
method provides the activity instance into the graph, so you can haveMyActivityModule
with no state, and just requestMyActivity
in your@Provides
methods.Doing this saves the module instance and allows the generated factories to be leaner.