2
I have a big question about the correct use of Dagger 2.10 or higher for android implementing according to the specifications of the Dagger documentation for Android.
Example code:
@Singleton
@Component(modules = {
AndroidInjectionModule.class,
ApplicationModulo.class,
ViewBuilderModule.class
})
public interface FipeApplicationComponent extends AndroidInjector<FipeApplication>{
@Component.Builder
interface Builder{
@BindsInstance
FipeApplicationComponent.Builder application(FipeApplication application);
@BindsInstance
FipeApplicationComponent.Builder urlBase(String urlBase);
FipeApplicationComponent build();
}
void inject(FipeApplication app);
}
- Bindsinstance
In the past when we wanted to link some instance of some class that needed to be instantiated outside the Dagger domains we passed this instance by the constructor. Now it is suggested to use @Bindsinstance within a @Component.Builder interface builder
- void inject
I see in some examples on the internet the use of void inject(Fipeapplication app) and as the previous item I asked here already has a:
...
@Component.Builder
interface Builder{
@BindsInstance
FipeApplicationComponent.Builder application(FipeApplication application);
...