Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to cancel requests #18

Closed
zuhair-naqvi opened this issue Aug 24, 2016 · 1 comment
Closed

How to cancel requests #18

zuhair-naqvi opened this issue Aug 24, 2016 · 1 comment

Comments

@zuhair-naqvi
Copy link

I'm implementing a query buffer to solve #16

I'm able to construct a batch query object after all individual queries have been added to the queue and I only want to execute the final, batch-query and cancel all other requests.

Does react-relay-network-layer support this?

@nodkz
Copy link
Collaborator

nodkz commented Aug 24, 2016

  // example of the custom inline middleware
  next => req => {
    return next(req);
  }

If you don't want pass request to internal fetch function, do not call next function. But you should return some promise.

  next => req => {
    const resultWithPayloadOrError = promiseThatProceedReqViaBuffer(req);
    return resultWithPayloadOrError;
  }

In promiseThatProceedReqViaBuffer:

requestList = [];
requestList.push(req.relayReqObj);

// after some tiny period of time, when you collect requests
queriesBatch(relayRequestList, fetchWithMiddleware)

Internally queriesBatch resolves/rejects all relay queries. But ideally somehow needs to pass resulting promise back to middleware (resultWithPayloadOrError).

@nodkz nodkz closed this as completed Dec 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants