Skip to content

Instantly share code, notes, and snippets.

@Macrofig
Created October 4, 2014 04:13
Show Gist options
  • Save Macrofig/df4cbff0aeea29d8a2a2 to your computer and use it in GitHub Desktop.
Save Macrofig/df4cbff0aeea29d8a2a2 to your computer and use it in GitHub Desktop.
Use Firebase REST API in CanJS.
//Still learning models... I'm wondering if this can be written better.
// This link explains how to cache the results to save on API calls...
// http://canjs.com/docs/can.Model.makeFindAll.html
var Posts = can.Model.extend({
findAll: 'GET https://myblog.firebaseio.com/website/posts.json',
makeFindAll: function( findAllData ){
var self = this;
return function(params, success, error){
return findAllData(params).then(function(data){
return self.models({data:data})
});
}
}
},{});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment