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

Koin Annotations: Add support for lazy injection of a list of dependencies #2126

Open
mihbatista opened this issue Feb 3, 2025 · 1 comment

Comments

@mihbatista
Copy link

mihbatista commented Feb 3, 2025

When using Koin Annotations, support also the lazy injection of a list of dependencies, besides the lazy injection of a dependency.

Is your feature request related to a problem? Please describe.
By having this feature more definitions can be migrated to Koin Annotations.

Describe the solution you'd like

@Single
class LoggerInMemoryDataSource : LoggerDataSource

@Single 
class LoggerInDatabase: LoggerDataSource

@Single
class LoggerAggregator(val lazyLoggers : Lazy<List<LoggerDataSource>>)

To generate the following DSL:

single { 

      LoggerAggregator(
             lazyLoggers = lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
                    getAll<LoggerDataSource>()
             }
      ) 
}

Describe alternatives you've considered
Using the single { } DSL

Target Koin project
My assumption is that the fitting places would be koin-core and koin-annotations / koin-ksp-compiler.

@uliluckas
Copy link

uliluckas commented Feb 14, 2025

Alternatively, a List<Lazy<LoggerDataSource>> would also be beneficial, as it would even allow to query the list length without instantiating any dependencies.

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