【发布时间】:2020-07-14 04:29:09
【问题描述】:
我需要将休息服务调用所获得的值返回给它的父级。问题是我正在调用休息服务(使用异步回调类),所以我需要“等待”结果,然后将其传递给其他地方。请查看以下sn-p。
config.addC(AppController.LOCALE.getMod(),new StringC<SomeEntry>() {
public String getValue(SomeEntry object) {
Rest.getSomething(AppController.getRest(), object.getId(), idAccess, null, null, new AsyncCallback<SomeStructureList>() {
@Override
public void onSuccess(final SomeStructureList result) {
return result.getSometing().getSomethingElse(); // i need to have access to variable result in the parent function getValue()
}
@Override
public void onFailure(Throwable caught) {
// fail...
}
});
return getRes(); //TODO as well
}
});
这样做的正确方法是什么?提前致谢。 编辑:我添加了更多代码以使其更清晰。
【问题讨论】:
标签: java rest gwt asynccallback