Closed johnyanarella closed 11 years ago
This feature and its associated unit tests have been implemented in the promises_aplus
branch and will be part of the Deft JS 0.9 release.
The reimplementation of Deft.Promise::always() is now available as part of the new Promises/A+ compliant rewrite of Deft JS's Promises.
See also: #82
promise.always(fn)
is akin to afinally
in atry..catch..finally
block (although it can occur anywhere a Promise chain).Originally envisioned as a shorthand for
promise.then(fn, fn)
,promise.always(fn)
has a couple odd quirks:The typical use case for
promise.always()
is to add handler logic that should be triggered regardless of whether the originating promise is fulfilled or rejected. In this scenario, the result or error parameter is ignored and the developer typically wouldn't think to inspect it and potentially rethrow it in the case of an Error.Consequently, it makes sense for
promise.always()
to be changed to eliminate these quirks:In the rare scenarios where the original behavior was actually desired,
promise.then(fn, fn)
can be used instead.