Skip to content

Multiple components injecting in same activity #230

Closed
@gaara87

Description

@gaara87

http://stackoverflow.com/questions/32341839/multiple-independent-component-injection

I've created an issue on stack overflow but i thought this repo would be more appropriate.

As you can see, why would such a configuration throw a compilation error? All the injections are satisfied by components individually. Yet it is expecting the first component to inject into the variable (B b).

Activity

amatkivskiy

amatkivskiy commented on Sep 14, 2015

@amatkivskiy

+1. This feature will help to decouple components by their responsibilities without need to create separate component (to merge that components into one) to inject multiple variables from different components.

netdpb

netdpb commented on Dec 10, 2015

@netdpb
Member

Dagger does expect to satisfy all injected dependencies of a type with one component (which may use subcomponents and/or component dependencies). JSR-330 requires implementations to inject all @Inject-annotated members.

Guice has an OptionalBinder feature that lets you inject Optional<Foo>, which is absent if there is no binding for Foo. If all your injected fields used that, you might get something like what you want.

Dagger does not have an analogous feature, but we're considering it.

I'm closing this bug, but feel free to continue the discussion on Stack Overflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @gaara87@amatkivskiy@netdpb

        Issue actions

          Multiple components injecting in same activity · Issue #230 · google/dagger