JSFiddle - React, Tailwind, and code Playground
by ronnjoe
JavaScript
var array = [
function(callback) {
console.log("first function called in " + (new Date().getTime() - timestamp) + "ms");
callback();
},
function(callback) {
console.log("second function called in " + (new Date().getTime() - timestamp) +
"ms");
callback();
},
function(callback) {
console.log("third function called in " + (new Date().getTime() - timestamp) + "ms");
callback();
}
];
timestamp = new Date().getTime();
function *generate(array,callback){
async function returnSelf(item) {
console.log("here");
return await item(callback);
}
/* async function flow() {
return await array.map(abc);
} */
for (var item of array) {
//abc(returnSelf);
//array.map(abc);
yield;
var generator = abc(returnSelf);
console.log(generator.next());
//console.log(generator.next());
//console.log(generator.next());
//abc(returnSelf);
}
function abc(item){
return item(callback);
//foo();
}
}
function foo(x){
console.log(" just printing ");
x();
}
var gent = generate(array, function() {
//Print the log only if the condition is statisfied
//if(myApp.isFunctionCompleted){
console.log("all functions finished in " + (new Date().getTime() - timestamp) + "ms");
//}
});
gent.next();
gent.next();
//console.log(gent.next());