Skip to main content

Module watch

Module watch 

Source
Expand description

--watch mode: continuously redraw terminal output at a fixed interval.

Callers pass in an async closure that renders one “frame” of output as a String, a refresh interval in milliseconds, and an optional cancellation receiver. The runner clears the screen, prints the rendered frame, waits for the interval, then repeats. It exits cleanly on SIGINT (Ctrl-C) or when the cancellation receiver fires.

Functions§

run_watch
Run render_fn in a loop, refreshing the terminal every interval_ms milliseconds. Returns as soon as Ctrl-C is received or the optional cancel channel fires.
run_watch_secs
Convenience wrapper for production use (no cancel channel, interval in seconds).