Closed agentmerlin closed 8 years ago
The only thing I can think of at the moment without radical changes is to have Idle
monitor an event such as Idle.interrupt
on rootScope, and when a message is received, it will just call interrupt
on itself. It feels a little hackish, but it may work.
ngidle could just use an $injector to load $http itself, rather than using DI. $http = $injector.get('$http')
That's true. He can also use $injector
in his interceptor.
.factory('IdleInterruptInterceptor', ['$injector', function($injector) {
// Manually interrupt the IdleService on every response
return {
response: function(response) {
$injector.get('Idle').interrupt();
return response;
}
};
}])
I've mentioned in other places that a future release should focus on modularizing the current functionality of ng-idle so people can pick and choose what they actually need, but this seems like a viable alternative for now.
I feel that adequate workarounds to make this work have been provided above.
Hi @HackedByChinese, I have a scenario where I have to renew my idle every single time a request is fired. I tried interrupt
and unwatch
and immediately watch
again in the interceptor. Because I did something in the interceptor, IdleTimeout
is not triggered. Because of this, a legitimate timeout is not timing out.
Any solutions?
This may just be more of a feature request, but I was attempting to use the the Idle service to strictly interrupt on http requests. Here is an example of the Interceptor service.
However, this is causing a circular dependency:
Uncaught Error: [$injector:cdep] Circular dependency found: $http <- Keepalive <- Idle <- IdleInterruptInterceptor <- $http
I'd love for the Idle service to be capable of being used with an interceptor, but I'm not sure the best way to go about adding that functionality in without dropping the dependency between Keepalive and $http or between Idle and Keepalive.