[英]How dependency graph works in Koin or Kodein?
I have Android/kotlin multi-module project. 我有Android / kotlin多模块项目。 Some of my modules are Singletone, such as Network and Analytics modules.
我的一些模块是Singletone,例如Network和Analytics模块。 They need Application context in order to be initialized.
他们需要Application上下文才能被初始化。
I am able to initialize Koin/Kodein in app
module. 我可以在
app
模块中初始化Koin / Kodein。 However, the problem is how to inject
application context into each module (since app module is not visible to Network/Analytics modules). 但是,问题在于如何
inject
应用程序上下文注入每个模块中(因为网络/分析模块看不到应用程序模块)。
Basically, my app module is deoendent to other modules only. 基本上,我的应用程序模块仅与其他模块无关。
As I recently started my project, I am evaluating Koin and Kodein to see which one is helping me the way I want. 在我最近开始我的项目时,我正在评估Koin和Kodein,以了解哪个人正在按我想要的方式帮助我。 That's why I am open to switch them.
这就是为什么我愿意切换它们。
Here is no dependency graph built like in Dagger: no code generation, no reflection - all is just function-bound. 这里没有像Dagger那样构建的依赖关系图:没有代码生成,没有反射-所有都是函数绑定的。
Application context is available through androidContext()
method. 应用程序上下文可通过
androidContext()
方法获得。
Modules mutual dependencies logic is described here . 模块的相互依赖性逻辑在这里描述。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.