From 54853dd62f63f4246fb367f8718bbc344c3487f9 Mon Sep 17 00:00:00 2001 From: Alex Currie-Clark Date: Mon, 6 Mar 2023 14:55:03 +0000 Subject: [PATCH] Update store readme to include that stores are only persisted when saved --- plugins/store/README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/store/README.md b/plugins/store/README.md index 807fd072..db8b568a 100644 --- a/plugins/store/README.md +++ b/plugins/store/README.md @@ -59,8 +59,15 @@ await store.set("some-key", { value: 5 }); const val = await store.get("some-key"); assert(val, { value: 5 }); + +await store.save(); // this manually saves the store, otherwise the store is saved when your app is closed ``` +### Persisting values +Values added to the store are not persisted between application loads unless: +1. The application is closed gracefully (plugin automatically saves) +2. The store is manually saved (using `store.save()`) + ## Usage from Rust You can also access Stores from Rust, you can create new stores: @@ -91,7 +98,7 @@ use tauri_plugin_store::with_store; let stores = app.state::>(); let path = PathBuf::from("path/to/the/storefile"); -with_store(app_handle, stores, path, |store| store.set("a".to_string(), json!("b"))) +with_store(app_handle, stores, path, |store| store.insert("a".to_string(), json!("b"))) ``` ## Contributing