Integrating multi scope dagger 2 components

纵然是瞬间 提交于 2019-12-24 17:43:36

问题


Preconditions

I have the following components:

  1. ApplicationCompoennt - With @ApplicationScope - This component contains LogModule. The logmodule @Provides Logger.
  2. ActivityComponent with @ActivityScope - This component contains MyActivityModule. Since one can't call the ctor of Activity explicitly, this module is used to inject the activity. This component depends on @ApplicationScope component, to use the Logger.
  3. BroadcastComponent with @BroadcastReceiverScope - This component contains BroadcastReceiverModule. Since one can't call the ctor of it explicitly (its present in the Android manifest file), this module is used to inject the broadcast receiver.

Problem:

I cant create ActivityComponent with 2 dependencies namely ApplicationComponent and BroadcastComponent, they being of different scopes, as we cant have dependent components of different scopes

How to get around this problem ?

来源:https://stackoverflow.com/questions/37097300/integrating-multi-scope-dagger-2-components

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!