简体   繁体   English

是否可以使用动态功能模块和 Koin 构建项目?

[英]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.

相关问题 是否可以使用 Koin 进行动态依赖注入 - Is Dynamic Dependency Injection with Koin possible Koin 2 在 Android 项目中创建功能范围的问题 - Koin 2 problem with creating scope for feature in Android project 在不使用bundletool的情况下从命令行构建具有动态功能模块的APK - Build apk with dynamic feature modules from command line without bundletool Isis 可以在没有 Google Play 的情况下使用动态功能模块 - Isis possible to use dynamic feature modules without Google play App Bundle - 动态功能模块:在动态功能模块错误中找不到基础项目 - App Bundle - Dynamic feature modules : Base project not found in dynamic feature module error Android 动态特性模块依赖 - Android dynamic feature modules dependencies 在多功能模块应用程序中,我在哪里加载和卸载 Koin 模块并保持可测试性 - Where do I load and unload Koin Modules, in a multi-feature module application and keep it testable 在 android 上重构为动态功能模块时,构建失败并显示“task:features:catalog:createDebugCompatibleScreenManifests FAILED” - Build fails with 'task :features:catalog:createDebugCompatibleScreenManifests FAILED' while refactoring to dynamic feature modules on android Koin 在模块之间共享实例 - Koin sharing instances between modules 动态功能模块中 Fragments 的 fragmentScenario Espresso 测试 - fragmentScenario Espresso tests of Fragments in Dynamic feature modules
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM