How to scope a class to a Viewmodel such that unle...
# koin
k
How to scope a class to a Viewmodel such that unless the viewmodel object is cleared that class will be present. And also ensure that only one object of that class is created even if it is injected multiple times. E.g. Screen A / Viewmodel A - here we inject a class . Navigate to Screen B / Viewmodel B - here we inject same class. Only one instance should be there even if there is change in configuration etc. as long as app is alive.
singleOf(::RealRepository) { bind<Repository>() }
Multiple objects of
RealRepository
are being created when it is injected in ViewModel A / B if a configuration change happens. Not sure if I'm missing something?
Created an Issue here, unless am missing something.