Ticker and Timer Pipes
Final provides prebuilt modal Pipes that push DateTime either periodically (ticker) or once after an interval / at a clock time (timer).
Factories create an unarmed pipe. Lifecycle words both initially arm and renew.
Ticker Pipe
Pipe.newTicker^ l.tick!
Interval.second l.tick@ pipe::tickerStart
// ...
l.tick@ pipe::tickerStop
pipe::tickerStart( iv:Interval p:Pipe -- )— start or restartpipe::tickerStop( p:Pipe -- )— stop ticks; pipe stays open- Do not
pipe::closea ticker pipe (fault) - Do
pipe::tickerStopwhen no more ticks are needed
Timer Pipe
Pipe.newTimer^ l.boom!
500 Interval.millisecond dt::* l.boom@ pipe::timerAfter
// or: someDateTime l.boom@ pipe::timerWhen
pipe::timerAfter( iv:Interval p:Pipe -- )— arm or re-arm after intervalpipe::timerWhen( when:DateTime p:Pipe -- )— arm or re-arm at time (past → immediate)- Does not self-close after fire; idle if not rearmed is harmless
- Do not
pipe::closea timer pipe (fault)
Example
See examples/threading/tick-tick-boom.fnl for both types of Pipes. Note that the example only uses the Timer pipe once, but you can easily use it in a re-fire mode, by re-arming it after it signals.