https://kotlinlang.org logo
Title
d

Davide Giuseppe Farella

04/15/2023, 5:46 PM
Hello people, I have a
ViewModel
like
class MyViewModel(
  @InjectedParam id: Id,
  private val something: Something
)
where
Something
also needs the
id
. Is there an easy way to “propagate” the
@InjectedParam
to
Something
?
a

arnaud.giuliani

04/18/2023, 8:04 AM
a tricky one that you can solve with dsl
viewModel {(id:String) -> MyViewModel(id, get {parametersOf(id)})
need to check how much we can chain/cascade arguments
d

Davide Giuseppe Farella

04/18/2023, 9:56 AM
Could it be something that we may want in Koin annotations, by propagating the
InjectedParam
to dependencies? I have mixed feelings about it, as you usually need the injected param in the ViewModel, but then you pass it to the use case as a function param. In my case I have a ViewModel and a
MoleculePresenter
, so it could make sense to tie the whole class to a single id, but I recognize that's not a common scenario