Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to scan more than one component at the time #180

Open
vivodikj opened this issue Oct 15, 2024 · 2 comments
Open

Possible to scan more than one component at the time #180

vivodikj opened this issue Oct 15, 2024 · 2 comments

Comments

@vivodikj
Copy link

Describe the solution you'd like
I would like to have my feature in one Koin Module [like in fakeModuleOld] and not in four separate modules which are then included in one common Koin Module [see example in package com.example.koinannotations.app.di].
If it will be possible make @ComponentScan repeatable or possible add array of packages to scan similar to @Module(includes = ...).

Describe alternatives you've considered
Alternative looks like @Module(includes = ...) :

@Module
@ComponentScan(
    values = [
        "com.example.koinannotations.presentation.features.fake", "com.example.koinannotations.business.features.fake",
        "com.example.koinannotations.data.features.fake", "com.example.koinannotations.infrastructure.sources.fake",
    ]
)
class FakeModuleWanted

Alternative with repeatable @ComponentScan :

@Module
@ComponentScan("com.example.koinannotations.presentation.features.fake")
@ComponentScan("com.example.koinannotations.business.features.fake")
@ComponentScan("com.example.koinannotations.data.features.fake")
@ComponentScan("com.example.koinannotations.infrastructure.sources.fake")
class FakeModuleWanted

How it looks in 'OLD' Koin without annotation, what I would like to achieve with 'NEW' Koin Annotations:

val fakeModuleOld = module {

    // FakeModule
    viewModelOf(::FakeViewModel)

    // FakeModuleBusiness
    factoryOf(::CheckIfKoinIsInstalledUseCase)
    factoryOf(::GetFakeDataUseCase)

    // FakeModuleData
    single<FakeRepository> { new(::FakeRepositoryImpl) }

    // FakeModuleInfrastructure
    single<FakeSource> { new(::FakeSourceImpl) }

}

Target Koin project
Link to my test project: https://gitlab.com/10vivodik/koin-annotations-test
The description is in package com.example.koinannotations.app.di

@arnaudgiuliani
Copy link
Member

Let's see what we can propose 👍

@vivodikj
Copy link
Author

vivodikj commented Oct 15, 2024

@arnaudgiuliani Thanks 🙂
I am creating my own local solution. I'll create a merge request if you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants