I'm learning Dagger and I'm just curious. I understand that if I plan to use Field Injection, I must have something like this:
@Singleton
@Component(modules={AppModule.class, NetModule.class})
public interface NetComponent {
void inject(MainActivity activity);
// void inject(MyFragment fragment);
}
where I list the classes that will have the field injection.
And also if this component is a parent of other components, I must have something like:
@Component(modules={ServiceModule.class,
ContextModule.class,
SchedulerModule.class})
@Singleton
public interface SingletonComponent {
Context appContext();
CatTable catTable();
CatDao catDao();
CatMapper catMapper();
CatRepository catRepository();
CatService catService();
Retrofit retrofit();
DatabaseManager databaseManager();
@Named("MAIN") Scheduler mainThreadScheduler();
@Named("BACKGROUND") Scheduler backgroundThreadScheduler();
}
But if I don't intend to do either one, can I have something like:
@Singleton
@Component(modules = arrayOf(DatabaseModule::class, AppModule::class,
ApiServiceModule::class))
interface AppComponent{
}
where the body is just empty.
(I'm aware that I will probably need field injection or child components, I just want to be sure that I'm not missing anything).