This code does not work:
var mappingOption = {
key: function (data) {
return ko.utils.unwrapObservable(data.id);
}
ko.mapping.fromJS(serverItems, mappingOption, viewModel.items);
I want to UNION of both items (viewModel.items and serverItems)
So ClassA has a collection of ClassB. On creation, it calls the mapping function, which has a create call back on a collection of items (of type ClassB) which calls the create class B constructor, passing in the relevant data.
ClassB then takes the data from the constructor, and merges it into itself.
I’m pretty sure this will work due to the key mapping of ClassB. But haven’t got the time to test it 😉