use an interval for tick

This commit is contained in:
Joe Ardent 2025-07-09 09:14:33 -07:00
parent 98a3a74490
commit dacef644a7

View file

@ -2,6 +2,7 @@ use std::{
collections::{BTreeMap, VecDeque},
io,
net::SocketAddr,
time::Duration,
};
use crossterm::event::{Event, EventStream, KeyCode, KeyEvent, KeyEventKind};
@ -73,6 +74,7 @@ impl App {
}
async fn handle_events(&mut self) -> io::Result<()> {
let mut tick = tokio::time::interval(Duration::from_millis(100));
tokio::select! {
event = self.events.next().fuse() => {
if let Some(Ok(evt)) = event {
@ -86,7 +88,7 @@ impl App {
}
}
}
_ = tokio::time::sleep(tokio::time::Duration::from_millis(100)) => {}
_ = tick.tick() => {}
}
Ok(())