Git Product home page Git Product logo

Comments (26)

cgruber avatar cgruber commented on April 28, 2024

I'd like to confirm that we don't want people injecting MembersInjector
directly. I believe we don't because we can inject the component. But I'd
like anyone who does want such to have a chance to speak up.

On Tue, Nov 11, 2014, 11:16 Jake Wharton [email protected] wrote:

As discussed.


Reply to this email directly or view it on GitHub
#63.

from dagger.

cgruber avatar cgruber commented on April 28, 2024

I think we found no more than a handful of such examples in google and all
of them could be replaced by injecting the component (if in a provides
method), or just storing the component.

On Sun, Nov 16, 2014, 10:00 Christian Gruber [email protected] wrote:

I'd like to confirm that we don't want people injecting MembersInjector
directly. I believe we don't because we can inject the component. But I'd
like anyone who does want such to have a chance to speak up.

On Tue, Nov 11, 2014, 11:16 Jake Wharton [email protected] wrote:

As discussed.


Reply to this email directly or view it on GitHub
#63.

from dagger.

sameb avatar sameb commented on April 28, 2024

Injecting the component could widen your dependencies, no? If the component
has a getFoo, injectBar and injectBaz method, seems wrong to pass it to
something that just wants to inject bar.

On Sun, Nov 16, 2014, 5:01 AM Christian Edward Gruber <
[email protected]> wrote:

I think we found no more than a handful of such examples in google and all
of them could be replaced by injecting the component (if in a provides
method), or just storing the component.

On Sun, Nov 16, 2014, 10:00 Christian Gruber [email protected] wrote:

I'd like to confirm that we don't want people injecting MembersInjector
directly. I believe we don't because we can inject the component. But
I'd
like anyone who does want such to have a chance to speak up.

On Tue, Nov 11, 2014, 11:16 Jake Wharton [email protected]
wrote:

As discussed.


Reply to this email directly or view it on GitHub
#63.


Reply to this email directly or view it on GitHub
#63 (comment).

from dagger.

gk5885 avatar gk5885 commented on April 28, 2024

@sameb, I think that's true, but I think the better question is really "who wants to do this in the first place?" All of the usages that I could find for Guice were just inspections using the SPI.

from dagger.

sameb avatar sameb commented on April 28, 2024

Yup, not very practical or necessary for Guice. Not sure how it'd play out
for Dagger. For the typical object that Android creates and needs members
injection by Dagger, does the user already have the component instance
handy? If so, then yeah, this seems like a moot point.

On Sun, Nov 16, 2014, 9:01 PM Gregory Kick [email protected] wrote:

@sameb https://github.com/sameb, I think that's true, but I think the
better question is really "who wants to do this in the first place?" All of
the usages that I could find for Guice were just inspections using the SPI.


Reply to this email directly or view it on GitHub
#63 (comment).

from dagger.

gk5885 avatar gk5885 commented on April 28, 2024

/me misclicked

Typically, those objects instantiated by Android are also tied to lifecycles, so they manage components themselves. So, yes, injection via the component is quite straightforward.

AFAICT, the only reason you'd want a MembersInjector instance would be if you wanted to inject members in an object from another @Injected object. That seems really niche. Plus, if you wanted to support that type of thing, you could always roll your own minimal interface and have a component interface extend it.

from dagger.

gk5885 avatar gk5885 commented on April 28, 2024

Oh, so to be clear, I'm +1 on this proposal.

from dagger.

JakeWharton avatar JakeWharton commented on April 28, 2024

you could always roll your own minimal interface and have a component interface extend it.

This is great because you can re-implement MembersInjector yourself. The one person who actually needs a general members injector (rather than a typed one) can just create it themselves.

from dagger.

sameb avatar sameb commented on April 28, 2024

SGTM. (If you're scouring the code to find examples where folks use it in Guice, you may also want to search for people using Injector.injectMembers, since many people don't know that MembersInjector<T> is a thing they can do.)

from dagger.

cgruber avatar cgruber commented on April 28, 2024

Bumping this, but we'll chat about it separately.

from dagger.

gk5885 avatar gk5885 commented on April 28, 2024

You know, the thing that I completely overlooked until seeing it now is that † had MembersInjector, so it'd seem a little weird for ‡ to just not have it. Since I think we were a little on the fence, that seems like a reasonable argument in favor of leaving it alone.

Factory can totally move though.

from dagger.

JakeWharton avatar JakeWharton commented on April 28, 2024

Dagger 1 didn't have components which are a more-explicit members injector.

from dagger.

gk5885 avatar gk5885 commented on April 28, 2024

That's true, but I see it as not really doing any harm and removing it adds cost to migrating from † to ‡.

from dagger.

cgruber avatar cgruber commented on April 28, 2024

Agreed. SGTM. I'll close this when I sync from head.

from dagger.

JakeWharton avatar JakeWharton commented on April 28, 2024

The harm is being the less-valuable of a redundant pair of mechanisms that are in the public API and thus require documentation, explanation, and support.

from dagger.

cgruber avatar cgruber commented on April 28, 2024

A semi-crappy thing would be to make dagger.internal.MembersInjector, and make dagger.MembersInjector deprecated and inherit from the former. Then there's a migration path, wtih the deprecation warning to go with it, and a note that it will go away in 2.1.

from dagger.

cgruber avatar cgruber commented on April 28, 2024

Never mind - that would require supporting injecting of both interfaces for backward compatibility, and that's ungood.

from dagger.

sameb avatar sameb commented on April 28, 2024

I'm not clear on how leaving MembersInjector helps migration to Dagger2. IIRC, Dagger2 doesn't support injecting a MembersInjector... so it'd just cause injection errors and confusion, no?

from dagger.

cgruber avatar cgruber commented on April 28, 2024

#140 moves Factory into internal.

from dagger.

gk5885 avatar gk5885 commented on April 28, 2024

@sameb, injecting a MembersInjector is something we support and I just sent the CL to test it.

from dagger.

cgruber avatar cgruber commented on April 28, 2024

Given that this is a public type that is referenced in user code, I think that's the deciding factor, and we leave MembersInjector as is.

from dagger.

JakeWharton avatar JakeWharton commented on April 28, 2024

that's the deciding factor

the major version bump disagrees with this

from dagger.

gk5885 avatar gk5885 commented on April 28, 2024

Oh, for sure we could get rid of it. There just didn't seem to be any real benefit. Smaller APIs are nice, but this is already a thing that we already support and moving it to a different package is just feels like churn.

from dagger.

cgruber avatar cgruber commented on April 28, 2024

@JakeWharton - to be clear, I didn't mean that the fact that Dagger 1.0 user code references it is the deciding factor, but the fact that it is, currently a supported (and tested) feature of the Dagger 2 code line. If we decided to disable that feature, it would then be in question.

from dagger.

ronshapiro avatar ronshapiro commented on April 28, 2024

Just stumbled upon this. I only see 16 usages of "MembersInjector<" in google, and most of them seem either like the wrong idea (someone is calling injectMembers(new Foo())) or extremely easy to migrate to just injecting the component or their own type.

I say that because we're working on inlining members injection now, which would mean that dagger's generated factories could remove their dependency on a MembersInjector, really making it obsolete.

If we were to remove it, it could make the internal model much simpler as we could replace all usages of BindingKey with Key and greatly simplify ResolvedBindings.

This would obviously have to go through a deprecation cycle (and I think for something like this we'd probably want something much more than 6 months), but it could be worth it.

from dagger.

cgruber avatar cgruber commented on April 28, 2024

from dagger.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.