JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://github.com/alex3683/UnifyJS/raw/master/unify.js"></script>
<div id="output"></div>
JavaScript
// create an asynchronous function that calls its callback after 2 seconds
var late = function( args ) {
window.setTimeout( function() {
args.callback( args.who );
}, 2000 );
};
// create an asynchronous function that calls its callback after 5 seconds
var later = function( callback, who ) {
window.setTimeout( function() {
callback( who );
}, 5000 );
};
// unify the these functions to call one callback after both are finished
Unify.add( late, { callback: Unify.CALLBACK, who: 'We are' } )
.add( later, Unify.CALLBACK, 'unified!' )
.invoke( function( one ) {
$('#output').text(one.join(" "));
} );