If I have a view model that looks like this when using the knockout mapping plugin. Does the plugin also wire up add/remove methods (or any other functions) or is it purely observables
var viewModel = {
var self = this;
foos: ko.mapping.fromJS([]),
loadInitialData: function() {
ko.mapping.fromJS(serverData, dataMappingOptions, viewModel.foos);
},
loadUpdatedData: function() {
ko.mapping.fromJS(serverData, dataMappingOptions, viewModel.foos);
}
};
The mapping plugin does not specifically add any additional functions to the resulting view model. It does augment observableArrays created by the mapping plugin with a few additional functions that work with the “keys” (http://knockoutjs.com/documentation/plugins-mapping.html#mapped_observable_array).
Additionally, the mapping plugin let’s you specify mapping options to control how your objects are created (http://knockoutjs.com/documentation/plugins-mapping.html#customizing_object_construction_using_create), which you could use to add extra functions or computed observables.