voliva / angular2-interceptors

79 stars 20 forks source link

Custom options to override in the response object #18

Open barocsi opened 7 years ago

barocsi commented 7 years ago

The case is the following:

  1. request made from view
  2. response 200, view processes result
  3. response 404 it is intercepted
  4. response object is returned to fulfill view promise or other subscribers
  5. I do not want view to catch the error nor to process the result because in 3. action was taken

in non typescript scenarios I was simply injected a property handled = true in the response object so the view/controller knew there is nothing further to do with the error message.

What is the best pattern to intercept and prevent bubbling but fulfill view/controller promises or observer subscribers?

Thanks

thekalinga commented 7 years ago

I have similar scenario aswell.

In OAuth2, if the refresh token is expired (which I will come to know when I send the request to server & get the response), I need to redirect the user to login page & don't want the interceptor chain(in the reverse order) to be executed.

So, there should be a provision to cancel the interceptor chain execution (interceptAfter) in the reverse order