Skip to content

Instantly share code, notes, and snippets.

@harboe
Last active December 18, 2015 03:58
Show Gist options
  • Save harboe/5721731 to your computer and use it in GitHub Desktop.
Save harboe/5721731 to your computer and use it in GitHub Desktop.
Knockout ObservableArray Map. Snippet from: Ryan Niemeyer - Getting the Most Out of Knockout.js @ http://vimeo.com/51103092
(function (undefined) {
//
// simple map function to extend the observableArray.
ko.observableArray.fn.map = function (data, Constructor) {
var mapped = ko.utils.arrayMap(data, function (item) {
return new Constructor(item);
});
this(mapped);
return this;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment