amzn / kotlin-inject-anvil

Extensions for the kotlin-inject dependency injection framework
Apache License 2.0
182 stars 2 forks source link

Provide `@SingleIn`, `@ForScope` and `AppScope` out of the box #16

Closed vRallev closed 5 days ago

vRallev commented 1 week ago

1 is a blocker for this issue.

Providing these classes out of the box will standardize them across projects and make onboarding of kotlin-inject-anvil easier.

The code for all platforms except JVM would look roughly like this:

@Scope
annotation class SingleIn(val scope: KClass<*>)

@Qualifier
annotation class ForScope(val scope: KClass<*>)

abstract class private constructor() AppScope

For JVM based platforms (including Android) we'd mark the annotations with JSR-330 annotation as well, so that they can be reused for Dagger 2 and Anvil to improve compatibility and ease migrations. JSR-330 would be added as compileOnly dependency and not exposed downstream. To support that we'd rely on expect - actual annotation classes.