aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/q.js
diff options
context:
space:
mode:
authorBrian Ford2013-08-09 09:45:35 -0700
committerIgor Minar2013-08-09 14:08:57 -0700
commitf078762d48d0d5d9796dcdf2cb0241198677582c (patch)
tree6c3fd2a011787fe701f83e9b55b7bd8ef069bc83 /src/ng/q.js
parent3ee744cc63a24b127d6a5f632934bb6ed2de275a (diff)
downloadangular.js-f078762d48d0d5d9796dcdf2cb0241198677582c.tar.bz2
chore($q): rename `promise.always` to `promise.finally`
BREAKING CHANGE: the `always` method has been renamed to `finally`. The reason for this change is to align `$q` with the Q promises library, despite the fact that this makes it a bit more difficult to use with non-ES5 browsers, like IE8. `finally` also goes well together with `catch` api that was added to $q recently and is part of the DOM promises standard. To migrate the code follow the example below: Before: $http.get('/foo').always(doSomething); After: $http.get('/foo').finally(doSomething); or for IE8 compatible code: $http.get('/foo')['finally'](doSomething);
Diffstat (limited to 'src/ng/q.js')
-rw-r--r--src/ng/q.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/ng/q.js b/src/ng/q.js
index e3c64645..307dc1b4 100644
--- a/src/ng/q.js
+++ b/src/ng/q.js
@@ -93,12 +93,16 @@
*
* - `catch(errorCallback)` – shorthand for `promise.then(null, errorCallback)`
*
- * - `always(callback)` – allows you to observe either the fulfillment or rejection of a promise,
+ * - `finally(callback)` – allows you to observe either the fulfillment or rejection of a promise,
* but to do so without modifying the final value. This is useful to release resources or do some
* clean-up that needs to be done whether the promise was rejected or resolved. See the [full
* specification](https://github.com/kriskowal/q/wiki/API-Reference#promisefinallycallback) for
* more information.
*
+ * Because `finally` is a reserved word in JavaScript and reserved keywords are not supported as
+ * property names by ES3, you'll need to invoke the method like `promise['finally'](callback)` to
+ * make your code IE8 compatible.
+ *
* # Chaining promises
*
* Because calling the `then` method of a promise returns a new derived promise, it is easily possible
@@ -274,7 +278,7 @@ function qFactory(nextTick, exceptionHandler) {
return this.then(null, callback);
},
- always: function(callback) {
+ "finally": function(callback) {
function makePromise(value, resolved) {
var result = defer();