Skip to main content

run_watch

Function run_watch 

Source
pub async fn run_watch<F, Fut>(
    interval_ms: u64,
    render_fn: F,
    cancel: Option<Receiver<()>>,
) -> Result<()>
where F: FnMut() -> Fut, Fut: Future<Output = Result<String>>,
Expand description

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.

§Arguments

  • interval_ms — refresh interval in milliseconds (clamped to ≥1 ms)
  • render_fn — async closure that returns a frame string or an error
  • cancel — optional oneshot receiver; when it fires the loop exits