Does angular/3rd party module for angular has support with network traffic monitoring, and how?
What I would like to establish is something similar to $watch, just for network traffic.
$scope.$watch('xhrTraffic', function(newval) {
newval - true when traffic starts/false when traffic ends
});
I want to be able to control when the browser is in network usage and when it's not.
It seems to me, that you need something like this
UPDATE
This code will help with managing XHR requests :
(function (){
'use strict';
angular.module( 'security.http-interceptor', [] )
.factory( 'securityInterceptor', ['$injector', '$q', '$rootScope', function ( $injector, $q, $rootScope ){
return {
'request' : function ( config ){
// do something on success
return config;
},
// optional method
'requestError' : function ( rejection ){
// do something on error
if ( canRecover( rejection ) ) {
return responseOrNewPromise
}
return $q.reject( rejection );
},
// optional method
'response' : function ( response ){
// do something on success
return response;
},
// optional method
'responseError' : function ( rejection ){
// do something on error
if ( canRecover( rejection ) ) {
return responseOrNewPromise
}
return $q.reject( rejection );
}
};
}] )
// We have to add the interceptor to the queue as a string because the interceptor depends upon service instances that are not available in the config block.
.config( ['$httpProvider', function ( $httpProvider ){
$httpProvider.interceptors.push( 'securityInterceptor' );
}] );
}());
And link before was an example of AUTH request check.
More about interceptors read here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.