Skip to content

Instantly share code, notes, and snippets.

@kevzlou7979
Last active March 16, 2017 15:23
Show Gist options
  • Save kevzlou7979/9fd2b67eb7e7a6d7ca9aeeaf66c256b8 to your computer and use it in GitHub Desktop.
Save kevzlou7979/9fd2b67eb7e7a6d7ca9aeeaf66c256b8 to your computer and use it in GitHub Desktop.
// Will setup the LoadResultCallback where the async widget has predefined UX upon loading the request
// and display the callback result returned by the server
LoadResultCallback<Car, MaterialButton> loadResultCallback = new LoadResultCallback<>(asyncButton);
// Let the user decide how they perform client to server mechanism (e.g RPC).
final CarServiceAsync carServiceAsync = GWT.create(FakeCarService.class);
carServiceAsync.getCar(1, new AsyncCallback<Car>() {
@Override
public void onFailure(Throwable throwable) {
loadResultCallback.onFailure(throwable);
}
@Override
public void onSuccess(Car car) {
loadResultCallback.onSuccess(car);
}
});
// Will perform the async load() method and call the asynccallback
loadResultCallback.load();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment