Hello. Isn't it possible to declare a component th...
# koin
t
Hello. Isn't it possible to declare a component that has more more than 22 dependencies with singleOf(::ClassA) ?
Copy code
public inline fun <reified R, reified T1, reified T2, reified T3, reified T4, reified T5, reified T6, reified T7, reified T8, reified T9, reified T10, reified T11, reified T12, reified T13, reified T14, reified T15, reified T16, reified T17, reified T18, reified T19, reified T20, reified T21, reified T22> org.koin.core.module.Module.factoryOf(crossinline constructor: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) -> R, noinline options: (org.koin.core.definition.BeanDefinition<R>.() -> kotlin.Unit)? /* from: org.koin.core.module.dsl.DefinitionOptions<R>? */ = COMPILED_CODE): org.koin.core.definition.KoinDefinition<R> { /* compiled code */ }
1
🤢 2
p
Have you had that possibility? If so you might consider a refactoring 🙂 Even when looking at ktlint that is already alot. But if that's a blocker and you really need that you can always create your own extension function. Not that hard. BTW using annotations or plain DSL this limitation isn't there as far as I know.
t
Yeah it's easy to create our own extension. I was more wondering about the why it is not possible. I call a bunch of use cases in a VM, how would suggest refactoring ? Genuine question.
p
No worries all good well I would have to see case by case. but usually I go with following approach : MainViewModel(tracker: Tracker, usecaseA: UsaeCaseA, usecaseB: UsecaseB.....) In this case a combaine the use case into one (Provide with Factory/Singleton) MainUsecase(usecaseA: UsaeCaseA, usecaseB: UsecaseB) MainViewModel(tracker: Tracker, mainUsecase: MainUsecase)
Usually having so many starts failing in builds because Tools like Sonar, Ktlint would start complaining about readability.
t
Thank you. I'll try to refactor with that on mind. I use to use Sonar on Eclipse back then but never used anything since I've been in Android dev. 😅