Created
June 8, 2012 11:04
-
-
Save chrismatheson/2895004 to your computer and use it in GitHub Desktop.
callbacks in loops
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var processQueue = function(data) { | |
if(typeof data === 'undefined'){ | |
//start of queue | |
data = new Object({}); | |
} | |
util.isError(data){ | |
console.error('error sending msg'); | |
console.error(util.inspect(data)); | |
//process.exit(1); | |
}else{ | |
// no data = start of queue so dont need to check respose data | |
if (messageQueue.length) { | |
// Bloody rate limit | |
twit.newDirectMessage(currentUserID, messageQueue.shift(), processQueue); | |
//console.log('now there are ' + messageQueue.length + ' messages left'); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment