Defer function calls

by Mohan 2012-09-20 23:40:39



Defer function calls
var opList = [];
function deferCall( text, value ) {
opList.push(arguments)
}
function doCall(func) {
while (opList.length)
func.apply(this,opList.shift());
}

deferCall( 'one', 1 );
deferCall( 'titi', 'toto' );
deferCall( 5, 'foo' );

function callLater(a,b) {

Print(a+', '+b);
}

doCall( callLater )
Prints:
one, 1
titi, toto


945
like
0
dislike
0
mail
flag

You must LOGIN to add comments