简体   繁体   English

在动态功能模块之间共享信息

[英]Share information between dynamic feature modules

I'm starting to use dynamic feature module and I have some doubts about how I shared information between modules 我开始使用动态功能模块,并且对如何在模块之间共享信息有一些疑问

For example: 例如:

Login Module 登录模块
- Make a call to the server and get a token to make the other requests -拨打服务器并获得令牌以发出其他请求
- Get a user session -获取用户会话

Movies Module 电影模块
- Make a request to the server but needs the token that was obtained in the login module -向服务器发出请求,但需要在登录模块中获得的令牌

Is there any way that the app project knows dynamic feature module , because dependency realization is inverse 应用程序项目有什么方法可以知道动态功能模块 ,因为依赖关系的实现是相反的

Login Module <-- app 登录模块<-应用
Movies Module <-- app 电影模块<-应用

Through this dependency relationship I could not call a login module class from the movie module 通过这种依赖关系,我无法从电影模块中调用登录模块类

Thank you for your answers. 谢谢您的回答。

You can add sub-module in the main module like I added linkedin-sdk module in my main module. 您可以在主模块中添加子模块,就像我在主模块中添加linkedin-sdk模块一样。

Just add sub-module in settings.gradle.kts & build.gradle (module level) files. 只需在settings.gradle.kts和build.gradle(模块级别)文件中添加子模块。 setting.gradle.kts file setting.gradle.kts文件

include(":app", ":linkedin-sdk")

build.gradle file build.gradle文件

implementation(project(":linkedin-sdk"))

In your case, if you want to access all data of login module then you have to make login module as a sub-module. 在您的情况下,如果要访问登录模块的所有数据,则必须将登录模块作为子模块。

Note: It is an example of build.gradle.kts 注意:这是build.gradle.kts的示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 具有 Android 架构导航的动态功能模块之间的 startActivityForResult() - startActivityForResult() between Dynamic Feature Modules with Android Architecture Navigation 使用导航组件在动态功能模块之间传递数据 - Passing data between dynamic feature modules using Navigation Component 在片段之间共享信息 - Share information between fragments Android 动态特性模块依赖 - Android dynamic feature modules dependencies 在模块之间共享测试类 - Share test classes between modules 是否可以使用动态功能模块和 Koin 构建项目? - Is it possible to build a project with Dynamic feature modules and Koin? 具有即时/(动态)功能模块的导航组件 - Navigation component with instant/(dynamic-)feature modules Android 带匕首刀柄的动态功能模块 - Android Dynamic Feature modules with Dagger Hilt 动态功能模块中 Fragments 的 fragmentScenario Espresso 测试 - fragmentScenario Espresso tests of Fragments in Dynamic feature modules 用于动态功能模块的合并测试 apk - Merged test apk for dynamic feature modules
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM