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

Option to abort last request while sending new one #82

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

frsdcorp
Copy link

We want to send requests any change event without delay.
But some requests (with 2-3-4 characters) processing much longer, than requests with many letters, so we abort previous xhr request to avoid previously sent callbacks.

Мурашкин Александр added 2 commits July 15, 2016 16:00
Aborting previous xhr while making new request
@jlbooker jlbooker added this to the v0.11.3 milestone Nov 1, 2016
@jlbooker jlbooker modified the milestones: v1.1.0, v1.2.0 Dec 21, 2016
} else {
pendingRequestsCount++;
pendingRequests[fingerprint] = this._send(o).done(done).fail(fail).always(always);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this works for me ...

                    pendingRequestsCount++;
                    if (o.abortLastRequest) {
                        o.beforeSend = function() {
                            if (lastXhrRequest) {
                                lastXhrRequest.abort();
                            }
                        };
                        pendingRequests[fingerprint] = this._send(o).done(done).fail(fail).always(always);
                        lastXhrRequest = pendingRequests[fingerprint];
                    } else {
                        pendingRequests[fingerprint] = this._send(o).done(done).fail(fail).always(always);
                    }

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

Successfully merging this pull request may close these issues.

3 participants