Skip to content

Support multiple scopes for components #433

Open
@vRallev

Description

@vRallev

We'd like to rename and migrate some of our scope annotations, e.g. today we use @SingleInAppScope, but would like to change this to @SingleIn(AppScope::class). Since this change needs to be rolled out in multiple repositories, this has to be done incrementally.

Dagger 2 supports multiple scopes per component and something like that would be valid:

@SingleInAppScope
@SingleIn(AppScope::class)
@Component
interface MyComponent

When checking if all providers use the correct scope, Dagger basically treats both scopes the same. This is great, because it would make the migration a lot easier.

However, kotlin-inject doesn't support multiple scopes for a component and simply picks the first one: https://github.com/evant/kotlin-inject/blob/main/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/InjectGenerator.kt#L199

Would you be open to support multiple scopes? Otherwise I don't see a way to migrate from one scope to another incrementally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions