https://kotlinlang.org logo
#dagger
Title
# dagger
m

Michael Vandendriessche

03/06/2023, 2:55 PM
In Hilt, can I reuse
@Qualifier
custom annotations? For my app I connect to a rest backend as well as an iot device. So I'm making these two annotations
Copy code
@Qualifier
@Retention(AnnotationRetention.RUNTIME)
annotation class Backend

@Qualifier
@Retention(AnnotationRetention.RUNTIME)
annotation class Device
I can use these annotations multiple times for different objects, right? Like use the
@Backend
custom annotation for the Retrofit instance as well as a provided String and maybe some other objects I will need later on.
f

FunkyMuse

03/06/2023, 2:59 PM
yes you can, every qualifier is reusable, think of
@Singleton
m

Michael Vandendriessche

03/06/2023, 4:00 PM
yep, makes sense. thank you!
a

Anselmo Alexandre

03/08/2023, 7:55 AM
Yes, you can differentiate your Retrofit instances using those custom annotations yes
137 Views