Pergunta

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?

Foi útil?

Solução

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;
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top