coderenaissance / knockout.viewmodel

The knockout viewmodel plugin is the fastest, smallest, cleanest, most flexible way to create a knockout viewmodel.
http://coderenaissance.github.com/knockout.viewmodel
105 stars 27 forks source link

new feature request pushAllFromModel #60

Open luiscaiano opened 10 years ago

luiscaiano commented 10 years ago

is it any problem to add a new feature to the array viewmodel ? in my code i added "pushAllFromModel" , right next to result.pushFromModel defenition, it seems to work fine, but them , i don't know all the inners of the lib. Can you add/comment about this ? if there is any issue/inpact , i would like to know.

            result.pushAllFromModel = function(items) {
                var result2 = [];

                for (p = 0, length = items.length; p < length; p++) {
                    result2[p] = recrusiveFrom(items[p], settings, newContext);
                }
                result.pushAll(result2);
            };
luiscaiano commented 10 years ago

almost forgot,

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