Repository navigation
Support Explicit Nested Scopes for improved hierarchy and Lifecycle-Safety #2338
oungsi2000
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi, I’m currently working on a project using Koin and wanted to share an idea regarding how scopes are handled.
Currently, implementing nested scopes in Koin often relies on managing scope keys and lifecycles manually, as shown below:
While Koin’s dynamic graph creation (especially in Android) is convenient, it can sometimes be implicit and lead to unintended behavior. I personally prefer a more explicit graph definition, similar to Dagger or Metro, where the hierarchy is strictly defined.
I have implemented a simple library that demonstrates this concept of explicit nesting:
https://github.com/Mole-Labs/mole-di
I’d love to hear your thoughts on this approach. Do you think this direction aligns with Koin’s roadmap, or are there specific architectural reasons for keeping the current flat scope definition?
Looking forward to your feedback!
All reactions