Dependency visualization for computed fields in a knockout

Is there a way in knockout.js to determine

  • what values ​​( ko.observableor ko.computed) depend on each other how (precedents / dependents) and
  • which HTML nodes (text binding for starters) depend on the current value of 1 so I can highlight them on the screen.

?

1 This means that I need a way to move from an HTML node to a connected one ko.subscribable, and not just to a view model, for example ko.dataFor(). This also seems impossible.


I created a web application that works like a spreadsheet - a set of numerical values ​​that are based on each other according to a set of business rules. Some of them are designed, some of them are provided to the user.

I am currently using my own JS library that does all the dependency tracking and dynamic screen refreshing. This works, but I would like to change it to knockout.js for convenience and elegance.

A knockout keeps track of this information somewhere. How can i use it?


For example, imagine a table (HTML table) that sums up several integers:

  | Abc
- + ---------
1 | 4 1 5
2 | 2
3 | 3 8
  • When the user clicks on cell B3, I would like to know that it depends on B1 and B2, and C3 depends on it.
  • When the user clicks on cell C3, I would like to know that it depends on A1, B1, C1, B2 and B3.
+5
source share
2 answers

(2.0+), . ko.computed, / . getDependencies, , / getDependents, .

+7

- , , . , , _subscriptionsToDependencies, , , .

getDependenciesCount, - , .

, , , . , , :

, , - _subscriptionsToDependencies V. getDependenciesCount: function (){return v.length}

, .

: , , KnockoutJS 2.1

+4

All Articles