Closed nathanboktae closed 9 years ago
Since this binding associates each element with a specific index rather than with a specific object, using arrayChange
wouldn't be possible.
So unshifting an item onto an observable array of 100, knockout 3.0's foreach
will be more performant because it will only result in one DOM node insertion, whereas knockout-repeat will re-template 101 nodes, correct?
Yes, that's correct. knockout-repeat works best when the array contents are fairly stable.
Good to know the pros and cons, thanks. I suspect most people have stable content, or just bulk replace the array anyways, making knockout-repeat useful still.
Knockout 3.0 added
arrayChange
subscriptions to get deltas of arrays. Sinceforeach
will support these, in a scenario that a small delta happens (push one item), thatforeach
could actually be quite a bit more performant thanknockout-repeat
if I'm understanding the code correctly.Or would it not? without a new binding context, individual items would be bound to an instance in the array, if that instance didn't change in the example of the push one item on the array, then would the result end up in just one DOM node insertion?