vendredi 9 juin 2017

dagger2 components - design pattern to not have so many inject calls in one interface

I am searching for a way or design pattern i can use so that dagger2 components to not have so many inject calls. Lets have a look at what i mean on a enterprise level:

Singleton
          @Component(modules = {AppModule.class, NetworkModule.class, RepositoryModule.class})
          public interface AppComponent {

              void inject(UserDataRepository target);

              void inject(DoStandardLoginUsecase target);

              void inject(NetworkSessionManager target);

              void inject(SharedPrefRepo target);

              void inject(getSharedPrefUsecase target);

              ActivitySubComponent plus(ActivityModule activityModule);

              PresenterSubComponent plus(PresenterModule presenterModule, UseCaseModule useCaseModule);
}
//.. this list is going to be gigantic in a year. how can i minimize it or make the inject calls somewhere else or group them ?

I need a way to group the inject calls somewhere else before they get out of control.

Aucun commentaire:

Enregistrer un commentaire