Skip to main content

run_async

Function run_async 

Source
pub fn run_async<M: Send + 'static>(
    f: impl FnMut(&mut Context, &mut Vec<M>) + Send + 'static,
) -> Result<Sender<M>>
Expand description

Run the TUI loop asynchronously with default configuration.

Requires the async feature. Spawns the render loop in a blocking thread and returns a tokio::sync::mpsc::Sender you can use to push messages from async tasks into the UI closure.

ยงExample

let tx = slt::run_async::<String>(|ui, messages| {
    for msg in messages.drain(..) {
        ui.text(msg);
    }
})?;
tx.send("hello from async".to_string()).await.ok();