Last active
August 29, 2015 13:55
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//.... | |
//.... | |
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