From dd9512b09e1a79fb83de7fa1d8bd52038d7fd368 Mon Sep 17 00:00:00 2001 From: Kris Zyp Date: Fri, 4 Apr 2014 14:47:40 -0600 Subject: [PATCH] Compute existing id prior to put, when creating notifications, refs #17783 --- store/Observable.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/store/Observable.js b/store/Observable.js index ce9e07eb86..b33e72e0e9 100644 --- a/store/Observable.js +++ b/store/Observable.js @@ -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); @@ -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{ @@ -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);