question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make class implementations of Subcomponents static if they do not reference the parent component

See original GitHub issue

Having an ImprintActivityComponent which is a subcomponent of ApplicationComponent which does not reference anything from the parent yields to the following generated implementation that could be made static:

private final class ImprintActivityComponentImpl implements ImprintActivityComponent {
 private Provider<ActionBarHelper> provideActionBarHelperProvider;

 private MembersInjector<ImprintActivity> imprintActivityMembersInjector;

 private ImprintActivityComponentImpl(ImprintActivityComponentBuilder builder) {
   assert builder != null;
   initialize(builder);
 }

 @SuppressWarnings("unchecked")
 private void initialize(final ImprintActivityComponentBuilder builder) {

   this.provideActionBarHelperProvider =
       DoubleCheck.provider(
           ActivityModule_ProvideActionBarHelperFactory.create(builder.imprintActivityModule));

   this.imprintActivityMembersInjector =
       ImprintActivity_MembersInjector.create(provideActionBarHelperProvider);
 }

 @Override
 public void injectMembers(ImprintActivity arg0) {
   imprintActivityMembersInjector.injectMembers(arg0);
 }
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
ronshapirocommented, Mar 1, 2017

@Subcomponents don’t know their parent component, and may sometimes be used in a context where they use the parent’s bindings and other times not. I think this is reasonable, just not a super high priority.

0reactions
ronshapirocommented, Mar 25, 2019

I’m going to claim this as infeasible. I don’t think the work required to make it happen is justified for such a small benefit.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Subcomponents - Dagger
Subcomponents are components that inherit and extend the object graph of a parent component. You can use them to partition your application's object...
Read more >
Call child method from parent - Stack Overflow
If best practice is to create a maze of logic to do something as simple as calling a child component's method - then...
Read more >
Composition vs Inheritance - React
React has a powerful composition model, and we recommend using composition instead of inheritance to reuse code between components. In this section, we...
Read more >
Component (Java Platform SE 7 ) - Oracle Help Center
A component is an object having a graphical representation that can be displayed on the screen and that can interact with the user....
Read more >
How to access parent component from child component. #15651
You can get parent instance reference inside OnInit with keyword this and pass as parameter or save in static class variable. In my...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found