I have written the following code. This piece of code just basically retrieving the value from the database. But the issue is happening that it is returning the value before completion of the onSuccess method.
How to mitigate the problem?
private static final SomeServiceAsync service = GWT.create(SomeService.class);
private static boolean valueIndicator = true;
private static boolean checkValueOfVariable() {
service.isValueTurnedOn(new AsyncCallback<Boolean>() {
@Override
public void onFailure(Throwable caught) {
Window.alert("Failed to retrieve value."+caught.getLocalizedMessage());
}
@Override
public void onSuccess(Boolean value) {
valueIndicator = value;
}
});
return valueIndicator;
}
I want to return the value after execution of onSuccess method.