Last active
February 17, 2016 19:47
-
-
Save Pacane/30462f0514c80206b7ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
requestStaticInjection(RestCallbackImpl.class); | |
bind(ConnectionErrorNotifier.class).to(ConnectionErrorConsoleNotifier.class).asEagerSingleton(); | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface ConnectionErrorNotifier extends ConnectionErrorEventHandler { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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