在google Guice中,我可以使用函数createInjector
创建基于多个模块的注入器。
因为我使用GWT.create
来设置GoogleGin中的注入器,是否可以基于多个AbstractGinModule
创建一个Ginjector。
如果我们不能,您如何组织代码以避免在同一个模块中拥有所有绑定?
答案 0 :(得分:7)
我使用以下代码创建使用多个模块的注入器:
@GinModules({ ClientDispatchModule.class, MyClientModule.class })
public interface MyAppGinjector extends Ginjector {
AppPresenter getAppPresenter();
PlaceManager getPlaceManager();
EventBus getEventBus();
}