Migrate single { lambda } to Koin Compiler

3 weeks ago 19
ARTICLE AD BOX

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?

Read Entire Article