Skip to main content

run_on_with

Function run_on_with 

Source
pub fn run_on_with<B, A>(
    term: Terminal<B>,
    app: A,
    options: RunOptions,
) -> Result<(), B::Error>
where B: Backend, A: App<B>,
Expand description

Drive an App with a blocking loop until it returns Flow::Exit, paced by options.

The zero-config run_on is equivalent to run_on_with(term, app, RunOptions::default()). Pass RunOptions::animated for a continuously-rendering loop capped at a fixed rate instead, sleeping out the remainder of each frame’s budget so update is called at even intervals rather than however fast the host can spin.

With RunOptions::is_event_driven true (the default), Flow::Idle blocks the loop on input (via Terminal::wait_for_input) instead of calling update again immediately: an idle app has nothing new to show, so there is no reason to burn CPU polling it at all, let alone faster than any configured rate. With event_driven false, an idle loop still waits out the remainder of the current target_fps interval (if set) before calling update again, rather than looping immediately, but never blocks on input.

§Errors

Returns the backend’s error if the automatic present() call fails. The loop stops and the terminal is dropped (running backend teardown) before the error is returned.