pub fn new() -> ModelExpand description
Creates a new stopwatch with a default 1-second tick interval.
This is the most commonly used constructor, providing a good balance between timing precision and system resource usage. The 1-second interval is suitable for most user-facing applications where elapsed time is displayed in seconds.
§Returns
A new Model instance with 1-second tick interval, initially stopped at zero elapsed time
§Examples
Basic stopwatch creation:
use bubbletea_widgets::stopwatch::new;
use std::time::Duration;
let stopwatch = new();
assert_eq!(stopwatch.interval, Duration::from_secs(1));
assert_eq!(stopwatch.elapsed(), Duration::ZERO);
assert!(!stopwatch.running());
assert!(stopwatch.id() > 0); // Has unique IDMultiple independent stopwatches:
use bubbletea_widgets::stopwatch::new;
let timer1 = new();
let timer2 = new();
// Each has a unique ID for independent operation
assert_ne!(timer1.id(), timer2.id());§Equivalent To
use bubbletea_widgets::stopwatch::new_with_interval;
use std::time::Duration;
let stopwatch = new_with_interval(Duration::from_secs(1));