Git Product home page Git Product logo

Comments (4)

lukaspili avatar lukaspili commented on July 18, 2024

Yes it cannot work like that.
superinterfaces is a no brainer that adds the extends Interface on the generated component.

I didn't add the support for extending a component because I think it's not something that you would do. If the parent component contains some inject(...) methods, you don't want to inherit them, but only the exposed dependencies.

What I do is to create the exposed dependencies in a separated interface.

public interface ApplicationDependencies {
   MyDep1 myDep1();
   MyDep2 myDep2();
}

@Component
public interface ApplicationComponent extends ApplicationDependencies {
   void inject(Application app);
}

The children components will extend the ApplicationDependencies and not the component itself. Like this you avoid to inherit the method void inject(Application app)

@Component(dependencies = ApplicationComponent.class)
public interface ActivityComponent extends ApplicationDependencies {
   void inject(Activity activity);
}

And with auto component:

@AutoComponent(dependencies = ApplicationComponent.class, superinterfaces = ApplicationDependencies.class)
public class MyActivity extends Activity {

}

I'm assuming this is the right way to do it, but I may be wrong.

from auto-dagger2.

dan-dr avatar dan-dr commented on July 18, 2024

Gotcha. Okay I guess you're right in this use case but I won't necessarily have an inject method to inherit, so it might be okay to support it - I mean I don't think this library should impose the way you write DI classes, but give you the power to mix it up a bit.

Thanks, great library:)

from auto-dagger2.

lukaspili avatar lukaspili commented on July 18, 2024

Valid point.
I'll include the support in the next version, beginning of January, as I'm quite busy right now.
Thanks for the feedback!

from auto-dagger2.

arok avatar arok commented on July 18, 2024

+1 for that feature

from auto-dagger2.

Related Issues (7)

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.