Skip to content

Instantly share code, notes, and snippets.

@tim-evans
Created March 28, 2011 15:53
Show Gist options
  • Save tim-evans/890710 to your computer and use it in GitHub Desktop.
Save tim-evans/890710 to your computer and use it in GitHub Desktop.
foo data source
MyApp.DataSource = SC.DataSource.extend({
fetch: function (store, query) {
var recordType = query.recordType,
guid = SC.guidFor(recordType);
if (guid === SC.guidFor(MyApp.FooRecord)) {
// handle Foo records here
return YES;
} else if (guid === SC.guidFor(MyApp.BarRecord)) {
// handle Bar records here
return YES;
}
return NO;
}
/**
call store.dataSourceDidComplete(storeKey) to mark the
record as 'created' by the server.
*/
createRecord: function (store, storeKey) {
var recordType = store.recordTypeFor(storeKey),
guid = SC.guidFor(recordType);
if (guid === SC.guidFor(MyApp.FooRecord)) {
// handle Foo records here
return YES;
} else if (guid === SC.guidFor(MyApp.BarRecord)) {
// handle Bar records here
return YES;
}
return NO;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment