mgonto/restangular

Cancel request - Angular 1.5

SamanthaAdrichem opened this issue · 1 comments

As of angular 1.5.0-rc.0 oblong-panoptikum (2015-12-09)

the cancel request option has been changed. This is not yet in your documentation.
Is this implemented yet? Or is your documentation version connected to their change?

https://github.com/angular/angular.js/blob/master/CHANGELOG.md

Using a promise as timeout is no longer supported and will log a warning. It never worked the way it was supposed to anyway.

Before:

var deferred = $q.defer();
var User = $resource('/api/user/:id', {id: '@id'}, {
  get: {method: 'GET', timeout: deferred.promise}
});

var user = User.get({id: 1});   // sends a request
deferred.resolve();             // aborts the request

// Now, we need to re-define User passing a new promise as timeout
// or else all subsequent requests from someAction will be aborted

User = $resource(...);
user = User.get({id: 2});
After:

var User = $resource('/api/user/:id', {id: '@id'}, {
  get: {method: 'GET', cancellable: true}
});

var user = User.get({id: 1});   // sends a request
user.$cancelRequest();      // aborts the request

user = User.get({id: 2});

nvm, that's only when you use $resource.