When using Koin/Dagger, is it usual to instantiate...
# android-architecture
o
When using Koin/Dagger, is it usual to instantiate a repository on login and delete it on logout? Or maintain a single repository during the app's lifecycle, and clear it's cache when logging out?
s
If I get your question right, your first idea is to create a subcomponent for login flow and have something like a
LoginRepository
in scope only when this LoginComponent is active, right.
I have implemented both of the ways you mentioned before (If my assumption above is correct). I like the subcomponent approach better.
g
Subcomponent approach is probably better solution, you may create dependencies with data available only for login user in constructor