首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在模块注释@ module ( subcomponent = ...)中声明子组件的示例

在模块注释@ module ( subcomponent = ...)中声明子组件的示例
EN

Stack Overflow用户
提问于 2019-01-17 18:58:25
回答 1查看 117关注 0票数 2

在dagger module annotation中声明subcomponent的用例是什么?例如:

代码语言:javascript
复制
@Module(subcomponents = ChildComponent.class)
public class ModuleB 

我已经阅读了文档,但找不到任何用法示例。

代码语言:javascript
复制
Any {@link Subcomponent}- or {@code @ProductionSubcomponent}-annotated classes which should be
   * children of the component in which this module is installed. A subcomponent may be listed in
   * more than one module in a component.
EN

回答 1

Stack Overflow用户

发布于 2019-01-17 21:53:31

您可以指定应该依赖于您的模块所属的组件的子组件类。

我有带有模块ModuleA和组件B的组件A。如果在ModuleA中指定subcomponents = B.class,则dagger将不会编译给

代码语言:javascript
复制
error: A doesn't have a @Subcomponent.Builder, which is required when used with @Module.subcomponents
@Module(subcomponents = {B.class})
^

除非组件BA的子组件。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54234408

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档