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

The Constructor DSL could inject parameters via getOrNull() #1812

Open
gary0707 opened this issue Mar 5, 2024 · 1 comment
Open

The Constructor DSL could inject parameters via getOrNull() #1812

gary0707 opened this issue Mar 5, 2024 · 1 comment
Labels
status:duplicated type:improvement Improving a current feature

Comments

@gary0707
Copy link

gary0707 commented Mar 5, 2024

Is your feature request related to a problem? Please describe.
In my code base, some of constructors use optional (nullable) parameters, which are not resolved correctly when I use the Constructor DSL like:

class FizzClass(val initialValue: Int?)

val someModule = module {
    factoryOf(::FizzClass)
}

The FizzClass is sometimes inject with a non-null value, but sometimes with null and to make that work I need to go with the classic DSL like:

val someModule = module {
    factory {
        FizzClass(initialValue = getOrNull())
    }
}

Describe the solution you'd like
It would be great to be able to use the Constructor DSL also with nullable injected params.

Describe alternatives you've considered
The only alternative I can see for now is the go with much more verbose classic Koin DSL.

Target Koin project
Koin-Core

@Nek-12
Copy link

Nek-12 commented Apr 17, 2024

Duplicate of #1456

@arnaudgiuliani arnaudgiuliani added type:improvement Improving a current feature status:duplicated labels May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:duplicated type:improvement Improving a current feature
Projects
None yet
Development

No branches or pull requests

3 participants