Is it possible to explicitly set params in a singl...
# koin
f
Is it possible to explicitly set params in a singleOf?
Copy code
class B
class A(b: B)

val module = module {
    singleOf(::A) {
        // parameters of B()
    }
}
m
Did you try ?
Copy code
class B
class A(b: B)

val module = module {
    singleOf(::A) {
        parametersOf(B())
    }
}
l
With this example it also looks simple to just go
Copy code
single { A(B()) }
a
currenty you can keep
singleOf(::A)
and use parametersOf
parametersOf(B())
... it will pass your
B
instance on the call stack. There is no other explicit rule yet
f
Doing this only creates the parameters and does not bind them to the object creation, is there something missing here? singleOf(::A) { parametersOf(B()) }
a
singleOf(::A) { parametersOf(B()) } won't do what you want
1
declare singleOf(::A) and call it with get<A> { parametersOf(B() )}