Closed ChristopherME closed 2 years ago
Any update on this? @ChristopherME
0 updates about it @scottkruse ...
@ChristopherME I hacked around this but doesn't feel great.
module { viewModel { val sharedComponent = get<SharedComponent>() ExampleViewModel( get { parametersOf(sharedComponent) } ) } factory { (sharedComponent: SharedComponent) -> OtherComponent(sharedComponent) } }
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I have the following situation. There are some objects I would like to instantiate only ONCE for the whole lifetime of my viewmodel. Something like @InstallIn(ViewModelComponent::class) does in dagger-hilt.
The following koin module is prepared for provide an instance of a viewmodel which is going to be injected into a fragment. The fragment can be replaced and added to the backstack (the viewmodel can survive the replace transaction).
With this configuration I ended up with two MovieMapperImpl() instances, which is bad.
Describe the solution you'd like Some clear explanation of how to scope some items to the same lifetime of my viewmodel.
Describe alternatives you've considered Single works but I dont want a singleton instance for a mapper that is used only in one specific feature.
Target Koin project Im currently using koin 3.0.1