hummingbird-me / kitsu-tools

:hammer: The tools we use to build Kitsu, the coolest platform for anime and manga
https://kitsu.app
Apache License 2.0
2.09k stars 264 forks source link

Cancel in-flight AJAX requests that aren't needed. #780

Closed trmcnvn closed 7 years ago

trmcnvn commented 7 years ago

ember-concurrency doesn't cancel any requests that are within a canceled task, and ember-data doesn't have a supported way of canceling a request.

We should investigate canceling these requests for the consumer as it's data that isn't relevant anymore.

Can be achieved by a method similar to: https://gist.github.com/vevix/00e7d68c7d16a7ec5cafc64ea92c6176

where yield'ed tasks would be wrapped in a try / finally block:

try {
  return yield get(this, 'store').query('model', { ... });
} finally {
  get(this, 'store').adapterFor('model').cancelRequests();
}