If I am not mislead by my memory, in Mathematica 6 a function Refresh
was introduced, having the options UpdateInterval
and TrackedSymbols
, to be used inside Dynamic
, that did not have these options. Anyway, nowadays both Dynamic
and Refresh
have these options, and already many years I never use Refresh
, with the feeling that it is a relict from long ago.
In (What is the point of Refresh if Dynamic has an UpdateInterval option?), more or less the same was remarked by @Tom Wellington:
I haven' t found an example where I can' t get rid of
Refresh[]
.
In the answer to that question, an example from the documentation was given. But in that example, we can replace Refresh
with Dynamic
with the same effect, so for me the question remains open.
Now I happened to find the following behaviour:
Column[{Dynamic[RandomReal[],UpdateInterval->0.5],
Slider[Dynamic[RandomReal[],UpdateInterval->0.5]],
Slider[Dynamic[Refresh[RandomReal[],UpdateInterval->0.5]]]}]
The first Dynamic
updates normally. With the same expression in a slider, it does not update at all, but when we wrap it in Refresh
, it updates.
Another example:
Column[{Slider[Dynamic[x]],
Slider[Dynamic[1-x, TrackedSymbols:>{}]],
Slider[Dynamic[1-x, TrackedSymbols:>{},UpdateInterval->0.5]],
Slider[Dynamic[Refresh[1-x, TrackedSymbols:>{},UpdateInterval->0.5]]]}]
When we move the first slider, the second and the third slider are immediately updated, while the second slider should not update at all and the third slider only two times per second. The last slider, with the first argument wrapped in Refresh
, behaves as expected.
It looks a little bit that we can use the options TrackedSymbols
and UpdateInterval
in Dynamic
only when this Dynamic
is a 'stand-alone' expression. As soon as it is part of a controller, we have to use Refresh
if we want to use these options. I have not seen this documentated. Am I right?
Dynamic
is aDynamicBox
; the slider is aSliderBox
with code, noDynamicBox
-es.) $\endgroup$Slider
withRefresh
inside behaves as standaloneDynamic[1 - x, TrackedSymbols :> {}, UpdateInterval -> .5]
. I mean service request to update object, then call from FE on pre.link and return from kernel. It even stops when you minimize window. $\endgroup$