在 google Guice 中,我可以使用函数 createInjector
创建基于多个模块的注入(inject)器.
因为我用GWT.create
要在 GoogleGin 中实例化注入(inject)器,是否可以基于多个 AbstractGinModule
创建一个 Ginjector .
如果我们不能,您如何组织代码以避免将所有绑定(bind)都放在同一个模块中?
最佳答案
我使用以下代码创建使用多个模块的注入(inject)器:
@GinModules({ ClientDispatchModule.class, MyClientModule.class })
public interface MyAppGinjector extends Ginjector {
AppPresenter getAppPresenter();
PlaceManager getPlaceManager();
EventBus getEventBus();
}
关于gwt - 用多个 AbstractModule 实例化一个注入(inject)器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1558855/