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
Muaz KADAN
10/26/2024, 11:36 AM
Did you try ?
Copy code
class B
class A(b: B)
val module = module {
singleOf(::A) {
parametersOf(B())
}
}
l
LeoColman
10/26/2024, 2:01 PM
With this example it also looks simple to just go
Copy code
single { A(B()) }
a
arnaud.giuliani
10/28/2024, 3:23 PM
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
Fergus Hewson
10/28/2024, 11:06 PM
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
arnaud.giuliani
10/30/2024, 7:46 AM
singleOf(::A) {
parametersOf(B())
}
won't do what you want
✅ 1
arnaud.giuliani
10/30/2024, 7:47 AM
declare singleOf(::A) and call it with get<A> { parametersOf(B() )}