The way to do this is to have canReveal
take a Callback<Boolean>
:
public void canReveal(Callback<Boolean> cb) {
if (!ClientState.isUserLoggedIn()) {
dispatcher.execute(..., new DispatchCallback<Result>() {
@Override
public void onSuccess(Result result) {
cb.onSuccess(result.isGoodOrWhatever());
}
});
} else {
cb.onSuccess(true); // User is logged in
}
}
Unfortunately there's no way to tell GWT to "wait" for the async callback, since that would basically freeze JS execution, since JS is single-threaded.