mod event_loop;
mod executors;
pub mod keybindings;
mod lifecycle;
pub mod modes;
mod setup;
pub use event_loop::{run_chat, RunChatOptions};
pub use keybindings::KeyLoopAction;
use std::sync::Arc;
use tokio::sync::Mutex;
use crate::core::app::App;
#[derive(Clone)]
pub struct AppHandle {
inner: Arc<Mutex<App>>,
}
impl AppHandle {
pub fn new(inner: Arc<Mutex<App>>) -> Self {
Self { inner }
}
pub async fn read<R>(&self, f: impl FnOnce(&App) -> R) -> R {
let guard = self.inner.lock().await;
f(&guard)
}
pub async fn update<R>(&self, f: impl FnOnce(&mut App) -> R) -> R {
let mut guard = self.inner.lock().await;
f(&mut guard)
}
}