[Android] Constructor injection for Interactors is disallowed
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 7.9k
- Forks
- 914
- PR merge metrics
- No merged PRs in 30d
Description
After completing tutorial 2, I attempted to improve the Dagger usage by using constructor injection where possible. I succeeded in making RootRouter, LoggedOutBuilder, and LoggedOutRouter constructor injected and was able to remove a few manually-written @Provides methods as a result.
Next, I wanted to convert RootInteractor to use constructor injection. This would allow me to remove its manual creation from RootBuilder and make its presenter member private and final. But it appears that several features in the tooling prevent me from trying this:
- First, it's explicitly disallowed by
InteractorAnnotationVerifier: "Interactor cannot have custom constructors - all dependencies and setup should happen in the builder of $type" - If I disable that check, I get compilation errors because the generated
Test*Interactorexpects a no-arg constructor. It looks like I could maybe rewriteInteractorTestGeneratorto be more flexible, but then I'd be getting pretty deep into the tools without knowing the framework that well.
So: Why is constructor injection of interactors disallowed?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading InteractorAnnotationVerifier and InteractorTestGenerator, then inspect RootInteractor and RootBuilder as described in the issue. Determine why custom constructors are rejected and how generated Test*Interactor depends on a no-argument constructor; done means documenting the constraint or defining the required tooling changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100