anx-api icon indicating copy to clipboard operation
anx-api copied to clipboard

Create an AnxApi.map function capable of canceling requests on first fail

Open tsantef opened this issue 8 years ago • 1 comments

Currently when currency limiting is enabled and a request fails there is no way to tell other related requests to cancel. I'm proposing a new shared map function that will allow requests to be grouped and cancelable as a unit.

tsantef avatar May 22 '17 16:05 tsantef

Looks like there is a way to cancel an axios request using a cancel token https://github.com/mzabriskie/axios#cancellation

The map function could receive an array of request objects and then call self._request on each of them with the additional cancelToken option. In the catch block of the promise.all you could then .cancel on each of the other promises. Or the map function could return a promise which in turn has a .cancel function that when called .cancels all of the request promises.

chrisdopuch avatar May 24 '17 04:05 chrisdopuch