Fix input events and drop spawning tokio

This commit is contained in:
2026-07-14 22:29:45 +02:00
parent 08edc981ee
commit b8162ebe3c
3 changed files with 16 additions and 8 deletions
+5 -3
View File
@@ -38,9 +38,11 @@ pub async fn run<A: App>(create_app: impl FnOnce(&state::Context) -> A) {
crossterm::terminal::enable_raw_mode().unwrap();
tokio::spawn(async move {
tx.send(Box::new(crossterm::event::read().unwrap()))
.await
.unwrap();
loop {
tx.send(Box::new(crossterm::event::read().unwrap()))
.await
.unwrap();
}
});
let mut app = create_app(&ctx);
+3 -1
View File
@@ -59,7 +59,9 @@ impl<'a, T> std::ops::DerefMut for StateGuard<'a, T> {
impl<'a, T> Drop for StateGuard<'a, T> {
fn drop(&mut self) {
if self.is_mutated {
self.tx.blocking_send(Box::new(Refresh)).unwrap()
let tx = self.tx.clone();
tokio::spawn(async move { tx.send(Box::new(Refresh)).await.unwrap() });
}
}
}