SingletonBinding
@Target(allowedTargets = [AnnotationTarget.CLASS] )
Annotation used to indicate that a class should be bound to a Singleton scope using Hilt. This annotation should be used on the implementation class and not on the interface.
Example usage:
@SingletonBinding
class FooImpl : Foo
interface Foo
Content copied to clipboard
This will generate the following Hilt module:
@Module
@InstallIn(SingletonComponent::class)
@OriginatingElement(
topLevelClass = FooImpl::class
)
interface FooImplModule {
@Binds
@Singleton
fun bindFoo(
fooImpl: FooImpl
): Foo
}
Content copied to clipboard