TiddlyTools/Time/Ticker is a StartupAction that invokes
<$action-timeout interval="1000" actions=<<ticker_actions>> />
to automatically trigger a <<ticker_actions>>
macro once per second.
One of the actions that is performed by the <<ticker_actions>>
macro is:
<$action-setfield $tiddler="$:/temp/time/ticker" text=<<now [UTC]YYYY0MM0DD0hh0mm0ss0XXX>>/>
which saves the current TWCore 17-digit UTC datetime stamp in $:/temp/time/ticker
.
As a result, there is an interesting “live update” side-effect that can be easily achieved without needing to use any additional $action-timeout
widgets…
Each time the contents of $:/temp/time/ticker
changes, the TWCore’s refresh mechanism “broadcasts” a global refresh event to all top-level rendered widgets. This refresh event is extremely optimized to only trigger re-rendering of widget content that is dependent upon changes to specified tiddler field values or calculated variables.
Try this:
Go to https://TiddlyTools.com and enable editing (click the “lock” toolbar icon in the upper-right corner of the page). Then create a new tiddler containing the following wikitext:
<<now 0hh:0mm:0ss.0XXX>>
This displays the current local time (including milliseconds). Note that the time display is only updated when that tiddler needs to be re-rendered, so the time that you see does not change unless you force a refresh of that tiddler’s content (e.g., by closing and re-opening the tiddler).
Next, change the tiddler’s content to:
<$let tick={{$:/temp/time/ticker}}><<now "0hh:0mm:0ss.0XXX">></$let>
Note that the value of the tick
variable depends the contents of $:/temp/time/ticker
. This creates a “refresh dependency” for the wikitext contained within the <$let>...</$let>
widget (i.e., the <<now>>
macro).
Since the $:/temp/time/ticker
content is being updated once per second (because of the <$action-timeout>
that was triggered by the TiddlyTools/Time/Ticker
StartupAction), the <<now "0hh:0mm:0ss.0XXX">>
macro gets automatically re-rendered, resulting in a “live” clock display that is updated once per second.
This same technique can be applied to ANY wikitext content (not just the <<now>>
macro), simply by enclosing it inside <$let tick={{$:/temp/time/ticker}}>...</$let>
.
enjoy,
-e