angular-restmod icon indicating copy to clipboard operation
angular-restmod copied to clipboard

No need to execute a canceled request

Open dirkgroenen opened this issue 10 years ago • 3 comments

I'm currently working on a validation plugin for my models and I'm encountering some weird things with the $send method.

When hooking in the before-save action I can cancel my request using this.$$action.canceled. Though, when I do this, the model still makes a $http request to the server. It would make more sense if the cancel check happens before making the $http request, wouldn't it?

I'm talking about the following lines of code:

this.$response = null;
this.$status = 'pending';
this.$dispatch('before-request', [_options]);

return $http(_options).then(wrapPromise(this, function() {
  if(action && action.canceled) {
    this.$status =  'canceled';
    this.$dispatch('after-request-cancel', []);
    return $q.reject(this);
  } else {
    this.$status = 'ok';
    this.$response = this.$last;
    this.$dispatch('after-request', [this.$response]);
    if(_success) _success.call(this, this.$response);
  }

Or is there an other way to cancel requests which I'm totally missing?

dirkgroenen avatar Sep 10 '15 11:09 dirkgroenen

+1 I also have this question

ldeboer avatar Sep 30 '15 01:09 ldeboer

+1 on this

karneaud avatar Mar 14 '16 20:03 karneaud

I don't know there seems to be some implementation of this but not sure why it is failing

karneaud avatar Mar 14 '16 21:03 karneaud