SteveSanderson / knockout-es5

Knockout.js meets ECMAScript 5 properties
156 stars 39 forks source link

Added "subscribe" method to the plain array #64

Closed revengineering closed 6 years ago

revengineering commented 6 years ago

Added "subscribe" method to the plain array, to allow for deeper event subscription without having to get the observable.

This avoids having to call ko.getObservable(model, "things") all over the data-bind attributes. You can just bind the tracked array same as you would an observableArray, and a binding that needs to subscribe can just call ".subscribe" on whatever kind of array it receives. See new test in arrays.tests.js for example.

revengineering commented 6 years ago

Withdrawing this pull request, as I suspect the code change I proposed may interfere with garbage collection. I have a reasonable alternate solution anyway, which requires no changes to this lib.