Suscribing to array changes using the new arraychange subscriptions in knockout 3.0
//.... | |
//.... | |
target.getChanges = function () { | |
var result = { | |
added: target.added(), | |
removed: target.removed() | |
}; | |
return result; | |
}; | |
target.subscribe(function(changes) { | |
ko.utils.arrayForEach(changes, function (change) { | |
switch (change.status) | |
{ | |
case "added": | |
addItem(change.value); | |
break; | |
case "deleted": | |
removeItem(change.value); | |
break; | |
} | |
}); | |
}, null, "arrayChange"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment