use an interval for tick
This commit is contained in:
parent
98a3a74490
commit
dacef644a7
1 changed files with 3 additions and 1 deletions
|
@ -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(())
|
||||
|
|
Loading…
Reference in a new issue