Function sequence

Source
pub fn sequence(cmds: Vec<Cmd>) -> Cmd
Expand description

Creates a command that executes a sequence of commands sequentially.

The commands in the sequence will be executed one after another in order. All messages produced by the commands will be collected and returned. This is useful when you need to perform operations that depend on the completion of previous operations.

§Arguments

  • cmds - A vector of commands to execute sequentially

§Returns

A command that executes all provided commands in sequence

§Examples

use bubbletea_rs::{command, Model, Msg};

struct MyModel;

impl Model for MyModel {
    fn init() -> (Self, Option<command::Cmd>) {
        let model = Self {};
        // Execute operations in order
        let cmd = command::sequence(vec![
            command::enter_alt_screen(),     // First, enter alt screen
            command::clear_screen(),         // Then clear it
            command::hide_cursor(),          // Finally hide the cursor
        ]);
        (model, Some(cmd))
    }
     
    fn update(&mut self, msg: Msg) -> Option<command::Cmd> {
        None
    }
     
    fn view(&self) -> String {
        "Ready".to_string()
    }
}