I\'ve got a model class in KnockoutJS which has multiple values that I\'d like to subscribe to. Each subscription will perform the same task, like so:
funct
Improving upon refactoring the function body into a variable, by turning the list of dependencies to track into a loop:
function CaseAssignmentZipCode(zipCode, userId, isNew) {
var self = this;
self.zipCode = ko.observable(zipCode);
self.userId = ko.observable(userId);
self.isNew = isNew;
self.isUpdated = false;
var handler = function () { self.isUpdated = true; };
ko.utils.arrayForEach([self.zipCode, self.userId], function(obs) {
obs.subscribe(handler);
});
}