I am just now taking my first read of the knockout library website's Getting Started documentation, and have a question about how to specify the target of the this keyword in the callback function sent to the knockout subscribe function, in the context of tracking changes to a set of objects whose properties are being observed.
I need to track 100 objects whose properties are initially null. Every one of those 100 objects can be described by the same view model:
var myViewModel = {
personName: ko.observable(null),
personAge: ko.observable(null)
};
var my100 = {
a1: myViewModel,
a2: myViewModel,
.
.
.
a100: myViewModel
}
The second argument of the subscribe() function "defines the value of this in the callback function". http://knockoutjs.com/documentation/observables.html
I am not sure what goes into the second argument when I need to know which one of those 100 objects has changed. When any property in the view model changes from null to a value, or from one value to another value, I want to know which object the change occurred in, e.g. a88.
myViewModel.personName.subscribe(myCallback, ?, "change");
myViewModel.personAge.subscribe(myCallback, ?, "change");
Knowing which property was changed would be good too, but it's more important that I know the object whose property has changed.