Ronan mailed me directly to notify me of this thread, here's a summary of my advice so far:
Hi Ronan,
Updating large numbers of arrays is not really what the mapping plugin is designed for, but have you looked at using the create/update callbacks? Using them, you can specify per-property how you would like to create/update them. In your case, you could override the creation of the array.
Let's say your array is called 'items'. Then, your mapping options would be something like:
var options = {
items: {
create: function(options) { return customCreateItems(options.data); }
}
};
Inside this callback, you could do something like:
var customCreateItems = function(items) {
var result = [];
for (var t=0;t<items.length;t++) {
result.push(ko.mapping.fromJS(items[t]); /* This maps a single item */
};
return result;
};
In other words, you would be bypassing the array mechanism of the mapping plugin and manage the array yourself. Your update callback would be identical, probably.
However, normally this only works for properties, so what you can do is wrap the array in a regular property and then use the callbacks.
I hope this helps! I will still try to look at solving the power-of-two complexity in the plugin, but for now this should also work.
If you need more suggestions, let me know.
With regards,
Roy