angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

Add timeout on $resource

Open berttheuwissen opened this issue 13 years ago • 4 comments

Add the possibility to specify a timeout on a $resource.

berttheuwissen avatar Mar 20 '13 07:03 berttheuwissen

Sorry, it isn't clear what you are asking for here. Closing for now, please reopen with a clear description if needed.

pkozlowski-opensource avatar Jul 19 '13 17:07 pkozlowski-opensource

It should be possible to let any rest call through the resource service of angular timeout after some time. The current implementation does not have a timeout and thus keeps waiting endlessly. This makes it impossible to detect if servers are down or not.

tomdw avatar Jul 20 '13 10:07 tomdw

In 1.1.x AngularJS supports configuration options like $http and the timeout property is one of the supported options: http://code.angularjs.org/1.1.5/docs/api/ngResource.$resource

pkozlowski-opensource avatar Jul 20 '13 11:07 pkozlowski-opensource

I understand how that makes sense for millisecond timeouts, however how would you be able to stop the get call below using a promise?

var User = $resource('/user/:userId', {userId:'@id'});
var user = User.get({userId:123}, function() {
  user.abc = true;
  user.$save();
});

paulistoan avatar May 08 '15 14:05 paulistoan