[英]Is it possible to build a project with Dynamic feature modules and Koin?
I have an app with different modules but the project is growing and we need to split the project in different Dynamic feature modules because the users (probably) would not need all the features.我有一个包含不同模块的应用程序,但该项目正在增长,我们需要将项目拆分为不同的动态功能模块,因为用户(可能)不需要所有功能。 My problem is that Koin needs to be started from the Application class with all the koin modules that the app is going to load but from that class I don't know which modules I have to load and :app modules does not import the other modules in gradle's dependencies (the other modules have to implement :app module).
我的问题是 Koin 需要从 Application 类启动,其中包含应用程序将要加载的所有 koin 模块,但是从该类我不知道我必须加载哪些模块,并且 :app 模块不导入其他模块在 gradle 的依赖项中(其他模块必须实现 :app 模块)。 My question is if it is a way to load Koin modules from an Activity in :app or the other loaded features.
我的问题是这是否是一种从 :app 中的 Activity 或其他加载的功能加载 Koin 模块的方法。
At the end, reading the documentation , I have found the solution.最后,阅读文档,我找到了解决方案。 Instad of using startKoin with all my feature modules, I can use
startKoin(...)
with no modules or base modules and then loadKoinModules(...)
( more ) in each dynamic feature to load their koin modules.在我所有的功能模块中使用
startKoin(...)
,我可以使用startKoin(...)
没有模块或基本模块,然后在每个动态功能中loadKoinModules(...)
( more ) 来加载它们的 koin 模块。 As a tip about dynamic features, it is good to have an interface with an entry point function that every feature implements to start the modules only once.作为关于动态特性的提示,最好有一个带有入口点函数的接口,每个特性实现的入口点函数只启动一次模块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.