Skip to content

dagger.android and multiple scoped components. #786

@makaroffandrey

Description

@makaroffandrey

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions