<@U0BLRBFMM> It was a pleasure meeting you at Kotl...
# kodein
s
@salomonbrys It was a pleasure meeting you at KotlinConf 2018 in Amsterdam. I talked to you and asked you briefly about scoping. This is a follow up and hopefully you can help me out a bit 🙂 Currently, our app has classes that are ‘global’: Kodein defines dependencies of a bunch of classes that have no scope (globally scoped). However, some of these classes need to be instantiated given the lifecycle other objects. There are two objects: AppSession and UserSession. An AppSession singleton lives from app-moves-in-the-foreground to app-moves-in-the-background. An UserSession singleton lives from user-login to either user-logout or app-moves-in-the-background (i.e. a UserSession ends when the AppSession ends) Some dependencies start (again) after an AppSession starts and become invalid when it ends; those singletons and multitons dependencies are discarded Also, UserSessions should be like multitons scoped to the current AppSession. Other dependencies start (again) after an UserSession starts and become invalid when it ends; those singletons and multitons dependencies are discarded How should I structure my dependency code (
bind<xxx>() with ....
) in my app to make this happen? Using
bind<xxx>() with scoped(AppSessionScope)
or
bind<xxx>() with scoped(UserSessionScope)
kinda works, but how do I make (all the items in) the
UserSessionScope
go out of scope as well when the
AppSessionScope
goes out of scope? Thanks!