This commit is contained in:
Tony
2024-10-03 09:44:46 +08:00
parent 98d4fc4e9b
commit 8975d10bb7
5 changed files with 24 additions and 31 deletions
+8 -1
View File
@@ -385,7 +385,14 @@ pub struct Store<R: Runtime> {
store: Arc<Mutex<StoreInner<R>>>,
}
impl<R: Runtime> Resource for Store<R> {}
impl<R: Runtime> Resource for Store<R> {
fn close(self: Arc<Self>) {
let store = self.store.lock().unwrap();
let collection = store.app.state::<StoreCollection>();
let mut stores = collection.stores.lock().unwrap();
stores.remove(&store.path);
}
}
impl<R: Runtime> Store<R> {
pub fn with_store<T>(&self, f: impl FnOnce(&mut StoreInner<R>) -> T) -> T {