Skip to content

Commit

Permalink
BUSY_DIRTY
Browse files Browse the repository at this point in the history
  • Loading branch information
onkis committed Apr 5, 2012
1 parent 345ab5b commit d93b1d3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
9 changes: 9 additions & 0 deletions frameworks/datastore/models/record.js
Expand Up @@ -1023,6 +1023,15 @@ SC.Record.mixin( /** @scope SC.Record */ {
@property {Number}
*/
BUSY: 0x0800, // 2048


/**
Useful because you can make changes to records that are commiting/refreshing
@property {Number}
*/
BUSY_DIRTY: 0x0802, // 2050


/**
Expand Down
36 changes: 27 additions & 9 deletions frameworks/datastore/system/store.js
Expand Up @@ -1446,7 +1446,8 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
// BUSY_LOADING, BUSY_CREATING, BUSY_COMMITTING, BUSY_REFRESH_CLEAN
// BUSY_REFRESH_DIRTY, BUSY_DESTROYING
if (status & K.BUSY) {
throw K.BUSY_ERROR ;
this.writeStatus(storeKey, K.BUSY_DIRTY);
//throw K.BUSY_ERROR ;

// if record is not in ready state, then it is not found.
// ERROR, EMPTY, DESTROYED_CLEAN, DESTROYED_DIRTY
Expand Down Expand Up @@ -2152,16 +2153,33 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {

// otherwise, determine proper state transition
if(status===K.BUSY_DESTROYING) {
throw K.BAD_STATE_ERROR ;
} else status = K.READY_CLEAN ;
throw K.BAD_STATE_ERROR;
}
//BUSY DIRTY
else if(status === K.BUSY_DIRTY){
status = K.READY_DIRTY;
this.writeStatus(storeKey, status);

if (newId) SC.Store.replaceIdFor(storeKey, newId);

statusOnly = newId ? NO : YES;
this.dataHashDidChange(storeKey, null, statusOnly);


}
//NORMAL
else {
status = K.READY_CLEAN;
this.writeStatus(storeKey, status);

if (dataHash) this.writeDataHash(storeKey, dataHash, status) ;

this.writeStatus(storeKey, status) ;
if (dataHash) this.writeDataHash(storeKey, dataHash, status) ;
if (newId) SC.Store.replaceIdFor(storeKey, newId);

statusOnly = dataHash || newId ? NO : YES;
this.dataHashDidChange(storeKey, null, statusOnly);
if (newId) SC.Store.replaceIdFor(storeKey, newId);

statusOnly = dataHash || newId ? NO : YES;
this.dataHashDidChange(storeKey, null, statusOnly);

}
//update callbacks
this._retreiveCallbackForStoreKey(storeKey);

Expand Down

0 comments on commit d93b1d3

Please sign in to comment.