Binding handlers and computed observables need to re-evaluate when their observable dependencies update. This means keeping track of dependencies and subscribing to them. Three objects make up the dependency-tracking feature: observables, computed observables, and the dependency-detection module.
Here's the basic overview. When a computed is evaluated, it asks ko.dependencyDetection
to start tracking things. When observables are accessed, they register themselves with ko.dependencyDetection
. When the computed is done evaluating, it records all of the registered dependencies and subscribes to each of them.
Okay, now let's look at some code.