Inspired by this (excellent) discussion of using Promises in javascript, I\'m trying to work out how I could use Deferred to chain together async and non-async functions, to
Wrapping a value into a promise is as simple as using $.when:
var promise = $.when( value );
Also, as of jQuery 1.6, you have a very simple chaining method (pipe):
var chained = functionThatReturnsAPromise().pipe(function( resolveValue ) {
return functionThatReturnsAnotherPromise( resolveValue );
});
chained.done(function() {
// Both asynchronous operations done in sequence
});
Hope this helps.