davesmiths
3/28/2014 - 11:53 AM

checkFor things to be true before doing a callback (js)

checkFor things to be true before doing a callback (js)

checkFor = function(check, callback, delay) {
	delay = delay || 250;
	if (check()) {
		callback();
	}
	else {
		setTimeout(function() {
			checkFor(check, callback, delay)
		}, delay);
	}
};