NomikOS
4/23/2015 - 4:22 PM

gistfile1.js

stuff1 = function(deferred) {
    setTimeout(function() {
        console.log("Stuff #1 is done!");
        deferred.resolve();
    }, 1000);
};

stuff2 = function(deferred) {
    setTimeout(function() {
        console.log("Stuff #2 is done!");
        deferred.resolve();
    }, 500);
};

stuff3 = function(deferred) {
    setTimeout(function() {
        console.log("Stuff #3 is done!");
        deferred.resolve();
    }, 500);
};

$.Deferred(stuff1).pipe(function() {
    return $.Deferred(stuff2)
}).pipe(function() {
    return $.Deferred(stuff3)
}).then(function() {
    console.log("done!");
});​