1
votes

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
    }
});
1

1 Answers

1
votes

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
    }
});