Skip to content

Instantly share code, notes, and snippets.

@wmill
Created April 1, 2013 03:13
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 wmill/5283049 to your computer and use it in GitHub Desktop.
Save wmill/5283049 to your computer and use it in GitHub Desktop.
App.RedditLink.reopenClass({
/* Use the Reddit JSON API to retrieve a list of links within a subreddit. Returns
a promise that will resolve to an array of `App.RedditLink` objects */
findAll: function(subreddit) {
return $.getJSON("http://www.reddit.com/r/" + subreddit + "/.json?jsonp=?").then(function(response) {
var links = [];
response.data.children.forEach(function (child) {
links.push(App.RedditLink.create(child.data));
});
return links;
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment