There are many examples of adding large datasets to a ko.observableArray using the underlying array such as this:

ko.observableArray.fn.pushAll = function(valuesToPush) {
var underlyingArray = this();
this.valueWillMutate();
ko.utils.arrayPushAll(underlyingArray, valuesToPush);
this.valueHasMutated();
return this;  //optional
};

The problem with doing it this way is I lose my observables. When I use chrome and pause in debugger, I get the values in my array rather than the function c() which is the observable wrap. I have to also observe many of these variables.

I found what does work is the following:

var model = @Html.Raw(Json.Encode(Model));
vm.POs = ko.mapping.fromJS(model.POs);

The problem is that this is slow. How do I use the underlying array to add but then add the observable wrap to each variable without performance issues?

Related posts

Recent Viewed