Skip to main content

tick

Function tick 

Source
pub fn tick<F>(duration: Duration, f: F) -> Cmd
where F: FnOnce(Instant) -> Message + Send + 'static,
Expand description

Command that ticks after a duration.

The tick runs for the full duration from when it’s invoked. To create periodic ticks, return another tick command from your update function when handling the tick message.

§Example

use bubbletea::{Cmd, tick, Message};
use std::time::{Duration, Instant};

struct TickMsg(Instant);

fn do_tick() -> Cmd {
    tick(Duration::from_secs(1), |t| Message::new(TickMsg(t)))
}