I have the simple example below :
function firstFunction(){
var d = jQuery.Deferred();
// some very time consuming asynchronous code...
setTimeout(function() {
console.log('1');
d.resolve();
}, 1000);
return d.promise();
}
function secondFunction(param){
console.log('parm = '+param);
var d = $.Deferred();
setTimeout(function() {
console.log('2');
d.resolve();
}, 10);
return d.promise();
}
firstFunction().pipe(secondFunction('OK'));
Resulat : param = OK 2 1 I lose the sync between functions. How t can pass parameter to secondFunction into pipe with sync?