我想在Receiver.onSuccess中收到RequestContext.edit(anObject)之后立即将它放在我的客户端数据库中,因为我已经可编辑了。不幸的是,当我这样做时,RequestFactory抱怨请求已在进行中。我怎样才能做到这一点?
requestContext.findOrganization(id).fire(new Receiver<OrganizationProxy>()
{
public void onSuccess(OrganizationProxy response)
{
database.put(requestContext.edit(response)); //fails because a request is already in progress
}
});
答案 0 :(得分:1)
我通过使用一次性请求上下文来创建请求,然后使用我更永久的请求上下文来编辑对象来解决这个问题:
temporaryRequestContext.findOrganization(id).fire(new Receiver<OrganizationProxy>()
{
public void onSuccess(OrganizationProxy response)
{
database.put(permanentRequestContext.edit(response)); //succeeds because it has not been fired, even though edit() has been called many times
}
});