Commit graph

14 commits

Author SHA1 Message Date
Lucas Galfasó
074b0675a1 fix($q): make $q.reject support finally and catch
Add support for the functions `finally` and `catch` to the
promise returned by `$q.reject`

Closes #6048
Closes #6076
2014-01-31 14:38:06 -05:00
Pete Bacon Darwin
2977067726 style($qSpec): add semi-colons 2013-10-02 14:12:35 +01:00
Igor Minar
5d9f42050a fix($q): reject should catch & forward exceptions thrown in errback 2013-08-24 12:49:46 -07:00
Vojta Jina
b89a4e49b9 test: rename / remove duplicate unit tests 2013-08-23 12:43:42 -07:00
Brian Ford
7d188d630c fix($q): fix forwarding resolution when callbacks aren't functions
Uses the changes from @jamestalmage's fix in #3535. (thanks!)

Closes #3535
2013-08-21 16:58:40 -07:00
Brian Ford
f078762d48 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);
2013-08-09 14:08:57 -07:00
bolasblack
a207665dad feat($q): add shorthand for defining promise error handlers
Now we can instead this

    promise.then(null, errorHandler)

with this

    promise.catch(errorhandler)

Closes #2048
Closes #3476
2013-08-09 09:02:58 -07:00
Pete Bacon Darwin
664526d69c fix($q): call reject() even if $exceptionHandler rethrows
Normally $exceptionHandler doesn't throw an exception.  It is normally
used just for logging and so on.  But if an application developer
implemented a version that did throw an exception then $q would never
have called reject() when converting an exception thrown inside a `then`
handler into a rejected promise.
2013-07-31 21:17:38 +01:00
Caio Cunha
2a5c355582 feat($q): added support to promise notification
It is now possible to notify a promise through deferred.notify() method.
Notifications are useful to provide a way to send progress information
to promise holders.
2013-07-14 23:11:46 -07:00
Chirayu Krishnappa
d884eb80a1 test($q): improve logging of callback invocations 2013-07-14 23:11:46 -07:00
Laurent Cozic
6605adf6d9 feat($q): add $q.always() method
Add $q.always(callback) method that is always called whether the promise is successful or fails; includes unit tests and updates
documentation.
2013-04-24 20:56:18 +01:00
Alexander Shtuchkin
e27bb6eb13 feat($q): $q.all() now accepts hash
When waiting for several promises at once, it is often desirable to
have them by name, not just by index in array.

Example of this kind of interface already implemented would be a
$routeProvider.when(url, {resolve: <hash of promises>}), where
resources/promises are given by names, and then results accessed
by names in controller.
2013-02-25 10:58:05 -08:00
Igor Minar
c0b78478a0 fix($q): $q.reject should forward callbacks if missing
$q.reject('some reason').then() should not blow up, but correctly
forward the callbacks instead.

Closes #845
2012-04-02 10:14:04 -07:00
Misko Hevery
2430f52bb9 chore(module): move files around in preparation for more modules 2012-03-28 11:16:35 -07:00
Renamed from test/service/qSpec.js (Browse further)