From f078762d48d0d5d9796dcdf2cb0241198677582c Mon Sep 17 00:00:00 2001 From: Brian Ford Date: Fri, 9 Aug 2013 09:45:35 -0700 Subject: 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); --- src/ng/q.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/ng') 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(); -- cgit v1.2.3