Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

feat($http): add notify callback for loading requests #9258

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/ng/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ function $HttpProvider() {
}

$httpBackend(config.method, url, reqData, done, reqHeaders, config.timeout,
config.withCredentials, config.responseType);
config.withCredentials, config.responseType, notify);
}

return promise;
Expand Down Expand Up @@ -1026,6 +1026,14 @@ function $HttpProvider() {
}


/**
* Notify callback registered to $httpBackend()
*/
function notify(xhr) {
deferred.notify(xhr);
}


/**
* Resolves the raw $http promise.
*/
Expand Down
4 changes: 3 additions & 1 deletion src/ng/httpBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
var ABORTED = -1;

// TODO(vojta): fix the signature
return function(method, url, post, callback, headers, timeout, withCredentials, responseType) {
return function(method, url, post, callback, headers, timeout, withCredentials, responseType, notify) {
var status;
$browser.$$incOutstandingRequestCount();
url = url || $browser.url();
Expand Down Expand Up @@ -103,6 +103,8 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
response,
responseHeaders,
statusText);
} else if (xhr && xhr.readyState == 3 && notify) {
notify(xhr);
}
};

Expand Down