Skip to content
Open
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
14 changes: 10 additions & 4 deletions lib/observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ angular.module('OmniBinder')
* the removed and added objects.
*/
this.observeObjectInCollection = function (context, collection, object, callback) {
function onObjectObserved (changes) {
function onObjectObserved(added, removed, changed, getOldValueFn) {
var changes = [{
added: added,
removed: removed,
changed: changed,
index: getOldValueFn(context.key)
}];

/*
An empty array to hold splice objects that will be created.
Splices will look like splices generated natively from Array.observe().
Expand All @@ -109,8 +116,7 @@ angular.module('OmniBinder')
}
}

this.observers[object] = onObjectObserved;
Object.observe(object, onObjectObserved);
this.observers[object] = new ObjectObserver(object, onObjectObserved);
};

/*
Expand Down Expand Up @@ -181,7 +187,7 @@ angular.module('OmniBinder')
if (change.removed.length) {
//Unobserve each item
angular.forEach(change.removed, function unObserve (obj) {
Object.unobserve(obj, self.observers[obj]);
self.observers[obj].close();
});
}
}
Expand Down