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

Inject collection of injectable types #1949

Open
CLOVIS-AI opened this issue Aug 22, 2024 · 0 comments
Open

Inject collection of injectable types #1949

CLOVIS-AI opened this issue Aug 22, 2024 · 0 comments
Milestone

Comments

@CLOVIS-AI
Copy link

Is your feature request related to a problem? Please describe.
I have a service "Trigger" that triggers an action in other services. The services that must be triggered implement a marker interface "Trigerrable".

I would like to declare the "Trigger" service without specifying all implementations of Triggerable manually.

Describe the solution you'd like

If a service is declared as such:

class Trigger(
    val services: List<Triggerrable>
) { … }

then singleOf(::Trigger) should automatically find all Triggerrable instances.

Describe alternatives you've considered

This currently works, but seems like a hack / isn't clear to understand:

single<List<Triggerrable>> {
    getAll(Triggerable::class)
}

singleOf(::Trigger)

Target Koin project

Koin Core

@arnaudgiuliani arnaudgiuliani added this to the 4.1 milestone Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants