Skip to content

Propagate data changes to children in NestedStores #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/sproutcore-datastore/lib/system/nested_store.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,11 @@ SC.NestedStore = SC.Store.extend(
if (!editables) editables = this.editables = [];
editables[storeKey] = 1 ; // use number for dense array support

var that = this;
this._propagateToChildren(storeKey, function(storeKey){
that.writeDataHash(storeKey, null, status);
});

return this ;
},

Expand Down Expand Up @@ -420,12 +425,20 @@ SC.NestedStore = SC.Store.extend(
var changes = this.chainedChanges;
if (!changes) changes = this.chainedChanges = SC.Set.create();

var that = this;

function iter(storeKey){
that.dataHashDidChange(storeKey, null, statusOnly, key);
}

for(idx=0;idx<len;idx++) {
if (isArray) storeKey = storeKeys[idx];
this._lock(storeKey);
this.revisions[storeKey] = rev;
changes.add(storeKey);
this._notifyRecordPropertyChange(storeKey, statusOnly, key);

this._propagateToChildren(storeKey, iter);
}

set(this, 'hasChanges', YES);
Expand Down
5 changes: 5 additions & 0 deletions packages/sproutcore-datastore/lib/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
var editables = this.editables;
if (editables) editables[storeKey] = 0 ;

var that = this;
this._propagateToChildren(storeKey, function(storeKey){
that.removeDataHash(storeKey, status);
});

return this ;
},

Expand Down