use crate::valtio::Valtio;
use tauri::{AppHandle, Manager, Runtime, State, WebviewWindow, Window};
use tauri_store::{Result, Store};
pub trait ManagerExt<R: Runtime>: Manager<R> {
fn valtio(&self) -> State<Valtio<R>> {
self.state::<Valtio<R>>()
}
fn with_store<F, T>(&self, id: impl AsRef<str>, f: F) -> Result<T>
where
F: FnOnce(&mut Store<R>) -> T,
{
self.valtio().with_store(id, f)
}
}
impl<R: Runtime> ManagerExt<R> for AppHandle<R> {}
impl<R: Runtime> ManagerExt<R> for WebviewWindow<R> {}
impl<R: Runtime> ManagerExt<R> for Window<R> {}