Permalink
Browse files

Revert "Trigger events in persistence.add()"

While triggering correct events for persistence.add(), this change introduced
duplicate events to be triggered for QueryCollection.prototype.add().

This reverts commit 1af51e8.
  • Loading branch information...
1 parent 1af51e8 commit 4f01c5c1f300754dd9af64fccae1e72694ebad38 @superquadratic superquadratic committed Feb 25, 2012
Showing with 2 additions and 13 deletions.
  1. +2 −13 lib/persistence.js
View
@@ -149,25 +149,15 @@ persistence.get = function(arg1, arg2) {
}
}
- persistence.objectAdded = function(obj) {
- persistence.objectChanged(obj, ['add', 'change']);
- }
-
persistence.objectRemoved = function(obj) {
- persistence.objectChanged(obj, ['change']);
- }
-
- persistence.objectChanged = function(obj, events) {
var entityName = obj._type;
if(this.queryCollectionCache[entityName]) {
var colls = this.queryCollectionCache[entityName];
for(var key in colls) {
if(colls.hasOwnProperty(key)) {
var coll = colls[key];
- if(coll._filter.match(obj)) { // matched the filter -> part of collection
- for(var i = 0; i < events.length; i++) {
- coll.triggerEvent(events[i], coll, obj);
- }
+ if(coll._filter.match(obj)) { // matched the filter -> was part of collection
+ coll.triggerEvent('change', coll, obj);
}
}
}
@@ -272,7 +262,6 @@ persistence.get = function(arg1, arg2) {
if (!this.trackedObjects[obj.id]) {
this.trackedObjects[obj.id] = obj;
if(obj._new) {
- this.objectAdded(obj);
for(var p in obj._data) {
if(obj._data.hasOwnProperty(p)) {
this.propertyChanged(obj, p, undefined, obj._data[p]);

0 comments on commit 4f01c5c

Please sign in to comment.