Example usage of change tracking in a complex view model, including a primitive array
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
var viewModel = { | |
Name: ko.observable("Pete"), | |
Age: ko.observable(29), | |
Skills: ko.observableArray([ | |
"TDD", "Knockout", "WebForms" | |
}), | |
Occupation: ko.observable("Developer") | |
}; | |
applyChangeTracking(viewModel); | |
viewModel.Occupation("Blogger"); | |
viewModel.Skills.push("Change tracking"); | |
viewModel.Skills.remove("WebForms"); | |
getChangesFromModel(viewModel); | |
/* -> { | |
"Skills": { | |
added: ["Change tracking"], | |
removed: ["WebForms"] | |
}, | |
Occupation: "Blogger" | |
} */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment