Skip to content

Instantly share code, notes, and snippets.

@beyond-code-github
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beyond-code-github/8736295 to your computer and use it in GitHub Desktop.
Save beyond-code-github/8736295 to your computer and use it in GitHub Desktop.
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