Let's create simple function:
SetAttributes[h, HoldFirst];
h[data_] := Dynamic[Grid[data], TrackedSymbols :> {data}]
test = RandomReal[1, {2, 2}];
h[test]
Now you can evaluate somewhere else:
test = RandomReal[1, {2, 2}];
And our grid will be updated. However if it is only a part of huge structure: (here not so huge ofc)
test2 = RandomReal[1, {2, 2, 2}];
h[ test2[[1]] ]
Evaluating test2 = RandomReal[1, {2, 2, 2}] will not change anything because what's inside TrackedSymbols is not a Symbol.
Anticipating questions:
Yes,
TrackedSymbolsis necessary, code above is only a minimal example.No I don't want to track whole
test2.No I don't want to split my
test2before passing it tohinto pieces that are meant to be tracked later. I need the referrence to be clear, if I do something inside with part oftest[[1]]thentestwill be updated. If I pass those new symbols then I will have to care about updatingtesteach time. Or maybe there is a way of dealing with this?
Do I want too much? :)
Gridmay be heavy layout that I want to recalculate only when necessary and here it would be even if you change part oftest2that is not used inGrid. – Kuba Oct 28 '14 at 15:02test3 := test2[[1]]and then useh[test3]? – WReach Oct 28 '14 at 18:18hthere may be a procedure to changedataso the oryginal table will not be updated. Moreover, your example will not be updated becausetest3is not changing unless evaluated. – Kuba Oct 28 '14 at 18:30HeadPart. Internally you assign a symbol to it and then track that symbol dynamically. – Mike Honeychurch Oct 28 '14 at 22:55TrackedSymbolstracks Symbols and it seems that you want it to track something other than a Symbol. Perhaps you would consider rewriting this question to focus on your performance goal instead which just might be answerable? – Mr.Wizard Dec 27 '14 at 22:30TrackedSymbolsis necessary but the same behaviour asTrackedSymbolsis? – Kuba Jan 05 '15 at 13:07