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 DSL not working as expected #2038

Open
Morons opened this issue Oct 30, 2024 · 1 comment
Open

Koin DSL not working as expected #2038

Morons opened this issue Oct 30, 2024 · 1 comment
Labels
question Usage question

Comments

@Morons
Copy link

Morons commented Oct 30, 2024

kotlin = "2.0.21"
koin-bom = "4.0.0"

Koin

koin-bom = { module = "io.insert-koin:koin-bom", version.ref = "koin-bom" }
koin-core = { module = "io.insert-koin:koin-core" }
koin-ktor = { module = "io.insert-koin:koin-ktor" }

Esencially these 3 lines attempt to do the same but the 2nd and third line uses DSL as per sample on the website
Koin DSL and Constructor DSL

image

  1. single { ChatRepositoryImpl(get()) } withOptions { bind() }
  2. singleOf(::ChatRepositoryImpl) bind ChatRepository::class
  3. singleOf(::ChatRepositoryImpl) { bind() }

Line 1. is the actual binding we need,
On the second and third line singleOf produces None of the following functions can be called with the arguments supplied:
On line 3 we are getting Unresolved reference. None of the following candidates is applicable because of receiver type mismatch
public inline fun BeanDefinition<out TypeVariable(T)>.bind(): Unit defined in org.koin.core.module.dsl

Please explain what happens

@arnaudgiuliani arnaudgiuliani added the question Usage question label Nov 15, 2024
@arnaudgiuliani
Copy link
Member

both 3 lines should work. Anything else on your config?

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

No branches or pull requests

2 participants