Last active
December 14, 2015 11:19
-
-
Save jimdalbano/5077916 to your computer and use it in GitHub Desktop.
This file contains 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
// Override DS.Adapter.didFindQuery only so that we can change the | |
// loader.populateArray function. Unfortunately, we can't just twiddle | |
// the populateArray function and let _super do the work. A hook would be nice. | |
didFindQuery: function(store, type, payload, recordArray) { | |
var loader = DS.loaderFor(store); | |
// ======================================== | |
// Here's the only difference! | |
// | |
if (type.toString() === 'App.Photo') { | |
if (payload.stat === 'ok') { | |
// bit of an assumption here. | |
recordArray.set('page', payload.photos.page); | |
recordArray.set('perPage', payload.photos.perpage); | |
recordArray.set('pages', payload.photos.pages); | |
recordArray.set('total', payload.photos.total); | |
} | |
payload = { 'photos' : payload.photos.photo }; | |
} | |
// ======================================== | |
loader.populateArray = function(data) { | |
recordArray.load(data); | |
}; | |
get(this, 'serializer').extractMany(loader, payload, type); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment