I have a KMM project where I need to pass string i...
# koin
j
I have a KMM project where I need to pass string in to constructor of repository that's in shard code e.g.
Copy code
single { params -> SomeRepository(params.get()) }
and then in android client I have a number of view models that the repository instance is injected into e.g.
Copy code
val someString = "someString"
val appModule = module {
    viewModel { ViewModel1(get { parametersOf(someString) }) }
    viewModel { ViewModel2(get(), get { parametersOf(someString) }) }
}
Feels like I'm missing something basic in terms of how this should be wired together? Or is this ok?
given it should be single instance of repository injected in to both view models it seems wrong then to have to provide that parameter twice (the way I'm doing it here at least)
what effect does the different form being used in 2nd view model have?
p
In my mind, the first viewModel has only a lambda in second parameter. And the second viewModel has a get (koin function) being called.
a
@John O'Reilly perhaps also in this case, you can use Koin property? or is it dynamic instance build?
j
Ah, ok...let me try that
Hmm, I think we'd need to be able to dynamically update that value....so perhaps different approach needed anyway
a
yes perhaps wrap it like a “provider” to help you provide this data where you need