JSFiddle - React, Tailwind, and code Playground
by nicholasstephan
JavaScript
function one() {
var promise = $.Deferred();
setTimeout(function() {
promise.resolve(1);
}, 500);
return promise;
}
function two() {
var promise = $.Deferred();
setTimeout(function() {
$.when(one()).then(function(a) {
promise.resolve(2);
});
}, 500);
return promise;
}
function three() {
return 3;
}
$.when(one(), two()).then(function(a, b) {
alert(a);
alert(b);
});
$.when(two(), three()).then(function(b, c) {
alert(b);
alert(c);
});