Uh oh!
There was an error while loading. Please reload this page.
feat($http): Added method to abort a pending request. (2nd attempt) - #1836
feat($http): Added method to abort a pending request. (2nd attempt)#1836dbinit wants to merge 1 commit into
Conversation
rickkln
commented
Jan 23, 2013
fredrikbonander
commented
Jan 23, 2013
@Rick-KLN, there's an quick fick for that. Edit http.js (done method) to check if digest is already running. if(!$rootScope.$$phase){$rootScope.$apply();}I forked it (https://github.com/The-Amazing-Society/angular.js/commit/623e12aea0a4fefa5d4225e72181b75bcec0dd5a) to implement this, had the same problem. |
dbinit
commented
Jan 23, 2013
Thanks guys. It looks like I incorrectly assumed that abort would fire the onreadystatechange event separately. I'll push a fix + test in a little bit here. |
fredrikbonander
commented
Jan 23, 2013
@dbinit Great work, I borrowed code from you fork. I would be real nice to get this merged in. |
rickkln
commented
Jan 23, 2013
Thanks a lot guys! |
TomKaltz
commented
Feb 20, 2013
Will this ever get merged into a production release? |
steinerj
commented
Mar 7, 2013
+1 on the merge :) |
New $http specific method "abort" for promises. There are many cases where a long-running request might need to be interrupted, e.g. a view change. Implementation details: - after calling abort(), the promise is guaranteed to be resolved with a rejection (unless it has already been resolved) - abort() returns true if successfully aborted (or already aborted), or false if the abort failed because the promise was already resolved - has mock $httpBackend support Closesangular#1159
g00fy-
commented
Apr 12, 2013
+1 |
bracketdash
commented
Apr 16, 2013
+1 for merging this. Also looking forward to something similar for $resource. |
svileng
commented
Apr 17, 2013
+1 |
knalli
commented
Apr 18, 2013
👍 (Probably needs to be merged again). Okay, I was surprised at the lack of http's abort... so: What does this PR hold back? How we can help? |
damrbaby
commented
Apr 18, 2013
How would you abort a pending request if you are using $resource? |
g00fy-
commented
Apr 18, 2013
@damrbaby add a |
dbinit
commented
Apr 18, 2013
Unfortunately I don't think this is going to be accepted as is. There is still ongoing discussion as to what the best approach is. Using a $q progress callback might be more suitable (see #2223). If returning a rejection from a progress callback could abort the XHR, it would be almost equivalent to this. |
dbinit
commented
Apr 19, 2013
I did a bit more research and found several implementations of Deferred/Promise that have an optional "canceler" feature. I've submitted #2452 to implement that feature. If it's accepted, adding $http cancellation would be fairly trivial. |
aminariana
commented
May 10, 2013
+1, |


Fixes issue #1159. Was pull request #1623.
Addressed issues brought up by Miško: