JSFiddle - React, Tailwind, and code Playground

by rwaldron

JavaScript

var count = 0, 
    asyncEvent = function() {
        var dfd = new $.Deferred();
        
        setTimeout(function(){
            count++;

            dfd.resolve();
        }, Math.floor(Math.random()*1500));

        return dfd.promise();
    };


$.when.apply( null, [ asyncEvent(), asyncEvent(), asyncEvent() ] ).then(function() {
    console.log( "Completed All: ", count );
});