I've been trying to extend an approach shown in GithubBrowserSample to support multiple Dagger Components.
I currently have two components: one with a @Singleton scope that is stored for the whole life of the application, and a dependent component scoped @PerUser, that gets recreated every time a new user logs in.
In the example, DispatchingAndroidInjector is used as AndroidInjector for injecting activities. DispatchingAndroidInjector is provided by Dagger, but I do not see a way to produce such an Injector (or a Map needed for its creation) from two components automatically using Dagger annotations. Should I create two maps and a new subclass of AndroidInjector to handle them?
Also, I see that @ContributesAndroidInjector is a convenient way to create Dagger components for each Activity or Fragment. I see that I can add @Modules and @Scopes to them, but I don't understand their lifecycle. Is there a way to keep these components through the Activity configuration changes?
I've been trying to extend an approach shown in GithubBrowserSample to support multiple Dagger Components.
I currently have two components: one with a
@Singletonscope that is stored for the whole life of the application, and a dependent component scoped@PerUser, that gets recreated every time a new user logs in.In the example,
DispatchingAndroidInjectoris used asAndroidInjectorfor injecting activities.DispatchingAndroidInjectoris provided by Dagger, but I do not see a way to produce such an Injector (or aMapneeded for its creation) from two components automatically using Dagger annotations. Should I create two maps and a new subclass ofAndroidInjectorto handle them?Also, I see that
@ContributesAndroidInjectoris a convenient way to create Dagger components for eachActivityorFragment. I see that I can add@Modules and@Scopes to them, but I don't understand their lifecycle. Is there a way to keep these components through the Activity configuration changes?