Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix($resource): fix interceptors and success/error callbacks
Browse files Browse the repository at this point in the history
Previously, action-specific interceptors and `success`/`error` callbacks
were executed in inconsistent relative orders and in a way that did not
meet the general expectation for interceptor behavior (e.g. ability to
recover from errors, performing asynchronous operations, etc).

This commit fixes the behavior to make it more consistent and expected.
The main differences are that `success`/`error` callbacks will now be
run _after_ `response`/`responseError` interceptors complete (even if
they return a promise) and correct callback will be called based on the
result of the interceptor (e.g. if the `responseError` interceptor
recovers from an error, the `success` calback will be called).
See also #9334 (comment).

Fixes #9334

BREAKING CHANGE:

If you are not using `success` or `error` callbacks with `$resource`,
your app should not be affected by this commit.

If you are using `success` or `error` callbacks (with or without
response interceptors), one (subtle) difference is that throwing an
error inside the callbacks will not propagate to the returned
`$promise`.

If you are using `success` or `error` callbacks with response
interceptors, the callbacks will now always run _after_ the interceptors
(and wait for them to resolve in case they return a promise).
Previously, the `error` callback was called before the `responseError`
interceptor and the `success` callback was synchronously called after
the `response` interceptor.
  • Loading branch information
gkalpak committed Feb 10, 2018
1 parent 02f4ca4 commit 14275c2
Show file tree
Hide file tree
Showing 2 changed files with 389 additions and 232 deletions.
Loading

0 comments on commit 14275c2

Please sign in to comment.