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