mbest / knockout-repeat

REPEAT binding for Knockout
http://mbest.github.io/knockout-repeat/
131 stars 18 forks source link

`arrayChange` support #19

Closed nathanboktae closed 9 years ago

nathanboktae commented 9 years ago

Knockout 3.0 added arrayChange subscriptions to get deltas of arrays. Since foreach will support these, in a scenario that a small delta happens (push one item), that foreach could actually be quite a bit more performant than knockout-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?

mbest commented 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.

nathanboktae commented 9 years ago

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?

mbest commented 9 years ago

Yes, that's correct. knockout-repeat works best when the array contents are fairly stable.

nathanboktae commented 9 years ago

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.