Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
// ...
requestStaticInjection(RestCallbackImpl.class);
bind(ConnectionErrorNotifier.class).to(ConnectionErrorConsoleNotifier.class).asEagerSingleton();
// ...
public class ConnectionErrorConsoleNotifier implements ConnectionErrorNotifier{
@Override
public void onConnectionError(ConnectionErrorEvent event) {
GWT.log("An error occured while communicating with the server");
}
@Inject
public ConnectionErrorConsoleNotifier(EventBus eventBus) {
eventBus.addHandler(ConnectionErrorEvent.TYPE, this);
}
}
public interface ConnectionErrorNotifier extends ConnectionErrorEventHandler {
}
public abstract class RestCallbackImpl<T> implements RestCallback<T>, HasHandlers {
@Inject
static EventBus eventBus;
private Response response;
@Override
public void setResponse(Response response) {
this.response = response;
}
@Override
public void onFailure(Throwable throwable) {
onError(response);
}
public void onError(Response response) {
ConnectionErrorEvent.fire(this);
}
@Override
public void fireEvent(GwtEvent<?> gwtEvent) {
eventBus.fireEventFromSource(gwtEvent, this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment