Created
October 4, 2014 04:13
-
-
Save Macrofig/df4cbff0aeea29d8a2a2 to your computer and use it in GitHub Desktop.
Use Firebase REST API in CanJS.
This file contains hidden or 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
//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