Reputation: 20890
I want to RequestContext.edit(anObject) immediately after I receive it in Receiver.onSuccess, so that I can put it in my client-side database as already editable. Unfortunately, when I do so, RequestFactory complains that a request is already in progress. How can I achieve this?
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
}
});
Upvotes: 1
Views: 1215
Reputation: 20890
I resolved this by using a disposable request context to create the request, and then using my more-permanent request context to edit the object:
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
}
});
Upvotes: 1