Skip to content

Instantly share code, notes, and snippets.

@FrozenCanuck
Created December 15, 2010 16:14
Show Gist options
  • Save FrozenCanuck/742174 to your computer and use it in GitHub Desktop.
Save FrozenCanuck/742174 to your computer and use it in GitHub Desktop.
datastore delegate proposal.js
// Would be placed into frameworks/datastore/mixins folder
SC.StoreDelegate = {
// Walk like a duck
isStoreDelegate: YES,
storeRecordWillRefresh(store, status, storeKey) { };
storeRecordDidRefresh(store, status, storeKey) { };
storeRecordWillCommit(store, status, storeKey) { };
storeRecordDidCommit(store, status, storeKey) { };
storeRecordWillDestroy(store, status, storeKey) { };
storeRecordDidDestroy(store, status, storeKey) { };
};
// Would update the store's refreshRecords, commitRecords and destroyRecords
// functions to notify the store delegate
SC.Store = SC.Object.extend(SC.StoreDelegate, SC.DelegateSupport, {
delegate: null,
storeDelegate: function() {
var del = this.get('delegate');
return this.delegateFor('isStoreDelegate', del);
}.property('delegate').cacheable()
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment