jquery/jquery — pull request #1178 by chrisalexander (2013-02-22 13:32:32+00:00)
Title: Implement custom deferred functions

We implemented using deferred / promises as part of our JS API. However I wanted to allow some additional custom callbacks.

This patch simply allows anyone to create a new deferred object but with additional custom methods on them. For now, they are simply like the notify / progress message, in that they do not affect any other methods and are not final.

Usage:

```javascript
// Provider sets up deferred with extra arg
var deferred = jQuery.Deferred( false, [ [ "callUserStart", "userStart" ] ] );
var promise = deferred.promise();

// The user can subscribe
promise.userStart(function(str) { alert(str); });

// The provider can call the user code
deferred.callUserStart("hello");
```

Test case included. Custom methods are included in the same way as the standard methods, but before them - so the standards will override them. Thus it is not possible for anyone calling jQuery.deferred() to be able to change the fundamental methods that people would expect to be there.