The following example shows three dynamic objects that all update when the value associated with the "d" key of association assoc is changed:
assoc = <|"d" -> 5, "e" -> 5, "f" -> 5|>;
d = e = f = 0;
{Dynamic[d = d + 1; assoc["d"], TrackedSymbols :> {assoc}],
Dynamic[e = e + 1; assoc["e"], TrackedSymbols :> {assoc}],
Dynamic[f = f + 1; assoc["f"], TrackedSymbols :> {assoc}]}
Dynamic[{d, e, f}]
Do[assoc["d"] = 1; assoc["d"] = 2, 100000];
Since two of these objects clearly do not depend on the value associated with "d" of assoc, unnecessary updating is occurring.
The following is a reformulation that performs fewer updates by avoiding use of associations:
assocD = assocE = assocF = 5;
d = e = f = 0;
{Dynamic[d = d + 1; assocD, TrackedSymbols :> {assocD}],
Dynamic[e = e + 1; assocE, TrackedSymbols :> {assocE}],
Dynamic[f = f + 1; assocF, TrackedSymbols :> {assocF}]}
Dynamic[{d, e, f}]
Do[assocD = 1; assocD = 2, 100000];
I would prefer to use associations as opposed to downvalues and pattern-matching, as associations are typically expected to be much faster and offer convenient data manipulation functions. Note that there may by many more than the 3 independent Dynamic elements shown in this example, and the association may hold many more unrelated entries. Are there any formulations with associations that would perform similarly?
Note that this does not work: TrackedSymbols :> {assoc["d"]}
Mathematica 11.0.1
Part
: How to track Part of Symbol but without general answer. Here is a more general solution to that problem with automatically created symbols: Allow multiple GUI elements to react dynamically to interaction with a single element $\endgroup$