Migrate single { lambda } to Koin Compiler


I am currently migrating an Android project that previously used Koin without the Koin Compiler Plugin, and I now want to adopt the plugin correctly.

I am unsure how to handle this part of the migration:

val databaseModule = module {
    // ...
    single { get<AppDatabase>().itemDao() }
}

I know I can do the following, but that forces me to use annotations which I didn't want to use:

@Module
class DatabaseProviderModule {
    // ...
    @Single
    fun provideItemDao(appDatabase: AppDatabase): ItemDao =
        appDatabase.itemDao()
}

Is there any alternative to this annotation style when using the compiler plugin?

0
Apr 4 at 1:24 PM
User Avatarme.at.coding
#android#kotlin#koin#android-koin

No answer found for this question yet.