Feature Request: Allow defining parent of built in components
See original GitHub issueHi folks, thank you for Hilt, particularly the documentation. I had a feature request/question. Is there any reason why @DefineComponent
allows declaring the parent component but the built in components do not? Ideally I’d like to do the following:
Declare a UserComponent as a child of ApplicationComponent Declare ActivityComponent to be the child of UserComponent
From what I gather this means I’d need to maintain the Manager around the UserComponent as well as any Activity/Fragment components that I create. I’d like to delegate to ActivityComponentManager and FragmentComponentManager.
Thank you kindly, I’m sure there is a reason why this does not work out of the box
Issue Analytics
- State:
- Created 3 years ago
- Reactions:26
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Parent, child and sibling relationships – Figma Help Center
If a parent contains more than one object, the child objects are siblings. Objects — like Frames, Groups and Components — can be...
Read more >Sharing data between child and parent directives ... - Angular
@Input() lets a parent component update data in the child component. Conversely, @Output() lets the child send data to a parent component.
Read more >Vue Parent and Child lifecycle hooks | by Brock Reece - Medium
A component becomes reactive just before the Created hook is fired, this means it will start to track changes of it's props before...
Read more >Breaking down CI/CD complexity with parent-child and multi ...
Customers request more features and the application needs to scale ... Parent-child pipelines help here, enabling you to extract cohesive ...
Read more >Using custom elements - Web Components | MDN
One of the key features of the Web Components standard is the ability ... this object allows you to register a custom element...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I made a minimal sample of what I think it takes to create a user scope. https://gist.github.com/digitalbuddha/4c63034969c107af3c98e098ae5ffbe7
So there are a few technical challenges that make this difficult to support.
The first is that custom components inserted in the tree are very likely to have arguments that need to be passed to the component builder. In your case, this would be the user id. The issue here is that because Hilt creates your components for you, we would have to figure out a way to get those arguments at the right time.
There’s also a question of storing the components we created for you. For example, is your inserted component one instance for the application or one instance per activity (or something else like one instance per user id?) Because Hilt hides the components, adding in hooks to control this would be complicated.
Finally, there’s a question of compatibility with extensions/libraries. For example, there are two basic paths for the activity component. The first is using the same
dagger.hilt.android.components.ActivityComponent
and just changing the parent somehow. That is difficult though because even ignoring the fact that the parent is statically defined, what does this mean for a library using@AndroidEntryPoint
that your app uses. Do they suddenly become injected from the user component as well? It likely isn’t always safe to make a library activity account-aware as maybe it could access account data in a way that isn’t apparent. The alternative is only your@AndroidEntryPoint
activities you declare are injected from yourActivityUserComponent
(like you defined in your example). But that also has problems because now things like the ViewModel extension don’t work because they installed bindings in the standard Hilt ActivityComponent.Anyway, I guess that is kind of a long way to say that supporting this would be very hard.