ded/reqwest — pull request #81 by geowa4 (2012-06-26 12:50:19+00:00)
Title: Add a promise implementation similar to jQuery

These two commits add a Promise implementation to Reqwest similar to jQuery's implementation, which is a slight deviation from CommonJS Promises/A. I decided to implement this more closely to jQuery's implementation because it's plenty good enough and it should be more familiar to a larger group of developers. If full compliance to the Promises/A specification is desired, I recommend using [q](https://github.com/kriskowal/q).

Two functions were added to Reqwest: `then` and `always`. The `then` function takes two parameters: a success handler and an error handler. The `always` function takes a single complete handler. Both return `this`.

This API differs from the Promises/A specification in that the `then` method returns `this` (like jQuery does) instead of a new Promise. Also, the `always` function (like jQuery) was added since Reqwest supports the `complete` option.

My motivations for adding these features were:
- I wanted an easy way to attach multiple sucess, error, and complete handlers to the Reqwest instance even _well after the AJAX response had been received_.
- I wanted to be able to use this library with [q](https://github.com/kriskowal/q), which has great support for the CommonJS Promises specifications. This required the Reqwest object to be "thenable".