Skip to content

Commit

Permalink
Compute existing id prior to put, when creating notifications, refs #…
Browse files Browse the repository at this point in the history
…17783
  • Loading branch information
kriszyp committed Apr 4, 2014
1 parent 85313a9 commit dd9512b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions store/Observable.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ var Observable = function(/*Store*/ store){
var original = store[method];
if(original){
store[method] = function(value){
var originalId;
if(method === 'put'){
originalId = store.getIdentity(value);
}
if(inMethod){
// if one method calls another (like add() calling put()) we don't want two events
return original.apply(this, arguments);
Expand All @@ -158,7 +162,7 @@ var Observable = function(/*Store*/ store){
try{
var results = original.apply(this, arguments);
when(results, function(results){
action((typeof results == "object" && results) || value);
action((typeof results == "object" && results) || value, originalId);
});
return results;
}finally{
Expand All @@ -168,8 +172,8 @@ var Observable = function(/*Store*/ store){
}
}
// monitor for updates by listening to these methods
whenFinished("put", function(object){
store.notify(object, store.getIdentity(object));
whenFinished("put", function(object, originalId){
store.notify(object, originalId);
});
whenFinished("add", function(object){
store.notify(object);
Expand Down

0 comments on commit dd9512b

Please sign in to comment.