use crate::valtio::{Valtio, ValtioMarker};
use tauri::{Manager, Runtime};
use tauri_store::{ManagerExt as _, Result, Store};
pub trait ManagerExt<R: Runtime>: Manager<R> {
fn valtio(&self) -> Valtio<'_, R> {
Valtio(
self
.app_handle()
.store_collection_with_marker::<ValtioMarker>(),
)
}
fn with_store<F, T>(&self, id: impl AsRef<str>, f: F) -> Result<T>
where
F: FnOnce(&mut Store<R, ValtioMarker>) -> T,
{
self
.app_handle()
.store_collection_with_marker::<ValtioMarker>()
.with_store(id, f)
}
}
impl<R: Runtime, T: Manager<R>> ManagerExt<R> for T {}