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

Pagination should only cancel _different_ pending "request result promises" #847

Closed
jandppw opened this issue Feb 18, 2014 · 2 comments
Closed

Comments

@jandppw
Copy link

jandppw commented Feb 18, 2014

Pagination.renderArray should not blindly cancel pending requests, but only if they are different from a new request.

We have code that "guards" remote requests against requesting the same information more than once concurrently (https://code.google.com/p/ppwcode/source/browse/javascript/util/oddsAndEnds/trunk/src/oddsAndEnds/promise/Arbiter.js). When "data" is asked, we check whether the "request" is the same or not, and if it is, and the request is still pending, we return the same Promise. That original Promise will later resolve for all callers of that "data".

That is just one example of sensibly returning the same Promise for different calls of a store.query.

This cannot be used with Pagination however, because Pagination (line 365 - 369) will blindly cancel a previous request, if it is not fulfilled yet, on refresh. The solution is to replace

if(this._topLevelRequest) {
  // Cancel previous async request that didn't finish
  this._topLevelRequest.cancel();
  delete this._topLevelRequest;
}

with

if(this._topLevelRequest && this._topLevelRequest !== results){
  // Cancel previous async request that didn't finish
  this._topLevelRequest.cancel();
  delete this._topLevelRequest;
}

This seems better in all cases.

@jandppw
Copy link
Author

jandppw commented Feb 19, 2014

https://code.google.com/p/ppwcode/source/browse/javascript/util/oddsAndEnds/trunk/src/oddsAndEnds/promise/Arbiter.js is changed to work around this with a reference counter, but the proposed change still seems something Pagination should do to me.

@ghost ghost closed this as completed in 00f8bfd Feb 27, 2014
@kfranqueiro
Copy link
Member

Thanks for the suggestion; I've incorporated it.

This issue was closed.
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