Partho Paul
10/26/2022, 11:55 AMarnaud.giuliani
10/26/2022, 11:56 AMarnaud.giuliani
10/26/2022, 11:56 AMPartho Paul
10/26/2022, 12:07 PMarnaud.giuliani
10/26/2022, 12:42 PMsingle { myParams -> MyInstance(myParams) }
?Partho Paul
10/26/2022, 12:52 PMserviceModule.kt:
fun serviceModule() = module {
factory { (param: MyParam) -> Service(param)) }
}
koin.kt:
fun Application.configureKoin() {
install(Koin) {
SLF4JLogger()
modules(
serviceModule(),
/* other modules */
)
}
}
service.kt:
fun doSomething(callParam: Param): Either<Throwable, String> = Either.catch {
val service: Service =
injectByComponent { parametersOf(param) }
service.doStuff()
}
utils.kt:
inline fun <reified T> injectByComponent(
noinline parameters: ParametersDefinition? = null
): T {
return object : KoinComponent {
val value: T by inject(parameters = parameters)
}.value
}
Using this, I’m getting the same error as other people are getting: java.lang.IllegalStateException: Deque is too big.
and ArrayDeque is empty.
The only difference is that they are using get()
to fetch instance and I’m using by inject()
arnaud.giuliani
10/28/2022, 4:45 PMnpresseault
11/12/2022, 9:55 PM