pub fn kill() -> CmdExpand description
Creates a command that kills the application immediately.
This command sends a KillMsg to the program, which will cause the event loop
to terminate as soon as possible with Error::ProgramKilled.
ยงExamples
use bubbletea_rs::{command, Model, Msg};
struct MyModel {
has_error: bool,
}
impl Model for MyModel {
fn init() -> (Self, Option<command::Cmd>) {
(Self { has_error: false }, None)
}
fn update(&mut self, msg: Msg) -> Option<command::Cmd> {
// Force kill on critical error
if self.has_error {
return Some(command::kill());
}
None
}
fn view(&self) -> String {
"Running...".to_string()
}
}