Chris Fillmore

    Chris Fillmore

    10 months ago
    Is there a way to bind a dependency twice? Once in SingletonComponent, once in ActivityComponent? In my use case I have two instances of a dependency: once in an Activity and once in a Service. The dependency itself depends on a
    Context
    , so I want to use the Activity context where possible. I suppose I could accomplish this binding with annotations, but I was wondering if there was another way.
    FunkyMuse

    FunkyMuse

    10 months ago
    You can use assisted inject for this and have the context as assisted dependency
    wasyl

    wasyl

    10 months ago
    IMO appropriate way to provide the same dependency twice in different scopes is to use qualifiers. Otherwise how would you decide which one to inject, if both are available?
    Chris Fillmore

    Chris Fillmore

    10 months ago
    Thanks for responding. In the end, because I needed one in an Activity and one in a Service, I put one in ActivityComponent and the other in ServiceComponent, so there was no collision.