nonJvmMain.com.squareup.anvil.annotations.optional.SingleIn.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of annotations-optional Show documentation
Show all versions of annotations-optional Show documentation
Optional annotations that we"ve found to be helpful with managing larger dependency graphs
The newest version!
package com.squareup.anvil.annotations.optional
import kotlin.annotation.AnnotationRetention.RUNTIME
import kotlin.reflect.KClass
import me.tatarka.inject.annotations.Scope as KotlinInjectScope
/**
* Identifies a type that the injector only instantiates once for the given
* [scope] marker.
*
* This can be used in combination with other Anvil annotations to avoid having
* to manually define scope annotations for each component and to maintain
* consistency.
*
* Component example:
* ```
* @SingleIn(AppScope::class)
* @MergeComponent(AppScope::class)
* interface AppComponent
* ```
*
* Contribution example:
* ```
* interface Authenticator
*
* @SingleIn(AppScope::class)
* @ContributesBinding(AppScope::class)
* class RealAuthenticator @Inject constructor() : Authenticator
* ```
*
* See Also: [@Scope](Scope)
*/
@KotlinInjectScope
@Retention(RUNTIME)
public actual annotation class SingleIn(
/**
* The marker that identifies this scope.
*/
actual val scope: KClass<*>,
)