I have a component that needs to be shared by vari...
# koin
s
I have a component that needs to be shared by various subcomponents within ViewModel, what is the best way to accomplish this? It needs to be the same instance
Copy code
ViewModel(sharedComponent, OtherComponent(sharedComponent))
pretty much a similar issue to this: https://github.com/InsertKoinIO/koin/issues/1080
right now im hacking around this by manually injecting everything downstream via
parametersOf
and it doesn't feel good
Copy code
module {
    viewModel {

        val sharedComponent = get<SharedComponent>()

        ExampleViewModel(
            get { parametersOf(sharedComponent) },
        )
    }

	factory { (sharedComponent: SharedComponent) ->
        OtherComponent(sharedComponent)
	}
}
a
one way to do that could be to use the Scope API, but it’s still manual also 🤔
but your way to inject inside is not bad also