Created
March 2, 2011 18:40
-
-
Save kuon/851440 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
fetch: function(S, query) { | |
var Q = SGIO.QUERIES; | |
console.log('fetch'); | |
S.dataSourceDidFetchQuery(query); // We fetch all queries immediately, then we will push the new data | |
console.log(query); | |
if(query === Q.ALL_CLIENT) { | |
SC.Request.getUrl('/clients.json').json() | |
.notify(this, '_didFetchRecords', S, SGIO.Client) | |
.send(); | |
} | |
return YES; | |
}, | |
_didFetchRecords:function(response, S, recordType) { | |
if(SC.ok(response)) { | |
response.get('body').forEach(function(rec) { | |
var key = S.storeKeyFor(recordType, rec.id); | |
S.writeDataHash(key, rec, SC.Record.READY_CLEAN); | |
S.dataHashDidChange(key); | |
}); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment