All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.squareup.anvil.annotations.optional.SingleIn.kt Maven / Gradle / Ivy

Go to download

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.Qualifier as KotlinInjectQualifier

/**
 * 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)
 */
@KotlinInjectQualifier
@Retention(RUNTIME)
public expect annotation class SingleIn(
  /**
   * The marker that identifies this scope.
   */
  val scope: KClass<*>,
)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy