How can I declare this code using Koin DSL as Koin...
# koin
p
How can I declare this code using Koin DSL as Koin Annotations?
factory *{* get<Retrofit>(QualifierRegularRetrofit).create(ProfileService::class._java_) *}*
And this one?
single *{* Room.databaseBuilder(_androidContext_(), StreamDatabase::class._java_, _DATABASE_NAME_).build() *}*
I don't know if it is the expected way, but I'm doing like it to handle the first case:
Copy code
@Module
@ComponentScan("com.x.y.feature_profile")
class ProfilePickerModule {

    @Factory
    fun service(): ProfileService {
        val koin = GlobalContext.get()
        val retrofit = koin.get<Retrofit>(QualifierRegularRetrofit)
        return retrofit.create(ProfileService::class.java)
    }

}
a
no all parameter are function parameters, then it would be just like:
Copy code
@Module
class ProfilePickerModule {

    @Factory
    fun service(retrofit : Retrofit): ProfileService {
        return retrofit.create(ProfileService::class.java)
    }

}
p
[1] @arnaud.giuliani in this case, in somewhere, I need to specify a retrofit @factory too right? How it can be written? [2] And how to annotate some dependency using pre-existing qualifiers? I found @Named in docs but I'm not sure if it fit as qualifiers.
a
Would be something like:
Copy code
@Module
class ProfilePickerModule {
    
    @Factory
    @Named("qualifier")
    fun service(): Retrofit {
        // Build Retrofit here ...
    }

    @Factory
    fun service(@Named("qualifier") retrofit : Retrofit): ProfileService {
        return retrofit.create(ProfileService::class.java)
    }

}
Type qualifier are coming soon for Koin Annotations
p
Hummm... now I get it. Thanks.
👍 1