문제

I'd like to use gwt-dispatch Command Patter implementation in my app. I'm using also mvp4g. How can I make DefaultDispatchAsync available to inject into my presenters using GIN or make it globally available, so I can access it from my presenters?

도움이 되었습니까?

해결책

You need to setup a bind for the DefaultDispatchAsync class in your gin module. This will setup the binding for the DispatchAsync interface that the DefaultDispatchAsync class implements. You can then add a DispatchAsync to your presenter constructor and have it injected by gin as required.

I normally then have my presenters contain a private DispatchAsync member, which i assign the injected DispatchAsync argument to inside the constructor. Then the dispatch can be used in the presenter class as required.

So in your GinModule's configure method, add the line

bind(DefaultDispatchAsync.class);

Then on your presenter constructor,

@Inject
public TestPresenter(/*Other injected arguments*/, final DispatchAsync dispatcher) {
   this.dispatcher = dispatcher;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top