Skip to content

Instantly share code, notes, and snippets.

@joshuaflanagan
Last active September 27, 2015 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuaflanagan/1302978 to your computer and use it in GitHub Desktop.
Save joshuaflanagan/1302978 to your computer and use it in GitHub Desktop.
Example of jquery.when
$.when( getTweets('austintexasgov'),
getTweets('greenling_com'),
getTweets('themomandpops')
).done(function(atxArgs, greenlingArgs, momandpopsArgs){
var allTweets = [].concat(atxArgs[0]).concat(greenlingArgs[0]).concat(momandpopsArgs[0]);
var sortedTweets = sortTweets(allTweets);
showTweets(sortedTweets);
});
var getTweets = function(user){
var url='http://twitter.com/status/user_timeline/' + user + '.json';
return $.get(url, {count:5}, null, 'jsonp');
}
// see it in action at http://jsfiddle.net/94PGy/4/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment