开发者

Using GIN and mvp4g

开发者 https://www.devze.com 2022-12-29 18:31 出处:网络
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 usin开发者_C百科g GIN or make i

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 usin开发者_C百科g 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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消