Created
December 15, 2010 05:09
-
-
Save joshholt/741655 to your computer and use it in GitHub Desktop.
Implementing fine grain callbacks for the SproutCore Datasource CRUD
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
| /* | |
| sproutcore/frameworks/datastore/data_sources/data_source.js | |
| Starting at line #106 | |
| */ | |
| /** | |
| Passing an optional params argument to allow callbacks in Record.refresh(); | |
| @param {Hash} [params] optional -- should be a hash with two callback functions | |
| successCallback and errorCallback | |
| */ | |
| retrieveRecords: function(store, storeKeys, ids, params) { | |
| return this._handleEach(store, storeKeys, this.retrieveRecord, ids, params); | |
| } |
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
| /* | |
| sproutcore/frameworks/datastore/system/nested_store.js | |
| Starting at line #466 | |
| */ | |
| /** | |
| Passing an optional params argument to allow callbacks in Record.refresh(); | |
| @param {Hash} [params] optional -- should be a hash with two callback functions | |
| successCallback and errorCallback | |
| */ | |
| // line 466 | |
| retrieveRecords: function(recordTypes, ids, storeKeys, isRefresh, params) { | |
| //... | |
| // line 520 | |
| return pstore.retrieveRecords(recordTypes, ids, storeKeys, isRefresh, params); | |
| //... | |
| }, |
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
| /* | |
| sproutcore/frameworks/datastore/model/record.js | |
| Starting at line #226 | |
| */ | |
| /** | |
| Passing an optional params argument to allow callbacks in Record.refresh(); | |
| @param {Hash} [params] optional -- should be a hash with two callback functions | |
| successCallback and errorCallback | |
| */ | |
| refresh: function(params) { | |
| this.get('store').refreshRecord(null, null, this.get('storeKey'), params); | |
| return this ; | |
| } |
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
| /* | |
| sproutcore/frameworks/datastore/system/store.js | |
| Starting at line #1426 | |
| */ | |
| /** | |
| Passing an optional params argument to allow callbacks in Record.refresh(); | |
| @param {Hash} [params] optional -- should be a hash with two callback functions | |
| successCallback and errorCallback | |
| */ | |
| // line 1426 | |
| retrieveRecords: function(recordTypes, ids, storeKeys, isRefresh, params) { | |
| // ... | |
| // line 1482 | |
| if (source) ok = source.retrieveRecords.call(source, this, ret, ids, params); | |
| // ... | |
| } | |
| /** | |
| Passing an optional params argument to allow callbacks in Record.refresh(); | |
| @param {Hash} [params] optional -- should be a hash with two callback functions | |
| successCallback and errorCallback | |
| */ | |
| // line 1526 | |
| retrieveRecord: function(recordType, id, storeKey, isRefresh, params) { | |
| // ... | |
| // line 1539 | |
| ret = this.retrieveRecords(recordType, id, storeKey, isRefresh, params); | |
| // ... | |
| } | |
| /** | |
| Passing an optional params argument to allow callbacks in Record.refresh(); | |
| @param {Hash} [params] optional -- should be a hash with two callback functions | |
| successCallback and errorCallback | |
| */ | |
| // lines 1554 - 1556 | |
| refreshRecord: function(recordType, id, storeKey, params) { | |
| return !!this.retrieveRecord(recordType, id, storeKey, YES, params); | |
| }, | |
| /** | |
| Passing an optional params argument to allow callbacks in Record.refresh(); | |
| @param {Hash} [params] optional -- should be a hash with two callback functions | |
| successCallback and errorCallback | |
| */ | |
| // lines 1568 - 1571 | |
| refreshRecords: function(recordTypes, ids, storeKeys, params) { | |
| var ret = this.retrieveRecords(recordTypes, ids, storeKeys, YES, params); | |
| return ret && ret.length>0; | |
| }, | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment