A timer can be used to execute an expression repeatedly at regular
intervals, for example to poll a service.
Recall the definition of
metronome from the previous chapter:
def metronome(t) = signal | Rwait(t) >> metronome()
The following example publishes "tick" once per second and "tock" once per
second after an initial half-second delay. The publications alternate: "tick
tock tick tock ...". Note that this program is not defined recursively;
the recursion is entirely contained within
metronome(1000) >> "tick" | Rwait(500) >> metronome(1000) >> "tock"