Created
March 28, 2011 15:53
-
-
Save tim-evans/890710 to your computer and use it in GitHub Desktop.
foo data source
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
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