Skip to content

Instantly share code, notes, and snippets.

@floydpink
Last active December 15, 2015 23:49
Show Gist options
  • Save floydpink/5342800 to your computer and use it in GitHub Desktop.
Save floydpink/5342800 to your computer and use it in GitHub Desktop.
Question about loading a few favorite repositories from Travis using ember-data. This is for the Travis-CI Mobile I am trying to put together here - https://github.com/floydpink/Travis-CI-www. Thank you for your help.
// I have a bunch of repo ids in an array
var favoriteRepos = ["451069","538603","291565","425941","496588","189854","323203","668498","557554","7934","207993"];
// How do we go about loading all these repos with the current ember-data implementation and the Travis API?
// This would be the 'Favorites' screen I am trying to implement here - http://floydpink.github.io/Travis-CI-www/#/favorites
// This is what I have tried unsuccessfully so far:
// This is in the repo model - https://github.com/floydpink/Travis-CI-www/blob/master/js/app/models/Repo.js
Repo.reopenClass({
favorites : function (favorites) {
// favorites would be an array of repo-ids like ["451069","538603"]
var faves = Ember.ArrayProxy.create({
isLoadedBinding : 'content.isLoaded',
content : Ember.A([])
});
favorites.forEach(function (favorite) {
faves.pushObject(Repo.find(favorite));
});
return faves;
}
});
// And in FavoritesController
this.set('content', Repo.favorites(favoriteRepos));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment