If I want to inject an instance of a specific class based on an annotation, I can do this in a Gin module:
bind(DiSecondary.class).annotatedWith(Special.class).to(DiSecondarySpecialImpl.class);
I also already have:
bind(DiSecondary.class).to(DiSecondaryImpl.class);
I can then retrieve the special instance into my DiMain (Composite wrapping a Panel) constructor with:
@Inject
public DiMain(@Special DiSecondary special) {
add(special);
}
But, if I want to code-split DiSecondarySpecialImpl using AsyncProvider, the analogous approach does not work:
@Inject
public DiMainAsync(@Special final AsyncProvider<DiSecondary> diSecondaryProvider) {
diSecondaryProvider.get(new AsyncCallback<DiSecondary>() {
public void onFailure(Throwable caught) {}
public void onSuccess(DiSecondary result) {
add(result);
}
});
}
I get a GWT compiler error. If I remove the annotation, then, of course, I get the non-special implementation.
Am I being unreasonable to expect that the compiler could apply the annotation to the async provider for the base class instead of the base class itself?
Is there a different route that I can use to get the desired behavior (annotation-based selection of an alternate async loaded class)?
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/B_PDh8TMfVwJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment