-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do you inject subcomponent factory #49
Comments
|
That kinda breaks the non-centralised nature of Anvil, since you still need access to the component instance to create subcomponents. Is this a fault of kotlin-inject-anvil or kotlin-inject? |
kotlin-inject, but it's the same in Dagger. You need the reference to the component for the parent-child relationship of the components. There's no way around it. Think of the |
Doh, the solution is just to add a
do you think it would be a good idea to add this to the README? I can make a PR if necessary.
I'm pretty sure that with Dagger's Anvil, you can directly inject subcomponent factories. |
To be honest, I never tried this 🙃 Instead of updating the README, this function should be generated. |
Generate a binding method for types annotated with `@ContributesSubcomponent.Factory` in the parent scope. This allows us to inject the factory type itself. Fixes #49
Generate a binding method for types annotated with `@ContributesSubcomponent.Factory` in the parent scope. This allows us to inject the factory type itself. Fixes #49
Thank you! |
Maybe a bit stupid question, but I've been trying to figure out how to actually inject the factory into something to instantiate the subcomponent:
But above fails with
Cannot find an @Inject constructor or provider for: RendererComponent.Factory
The text was updated successfully, but these errors were encountered: