chore(store): Update store readme (#270)

* Update store readme to include that stores are only persisted when saved
pull/272/head
Alex Currie-Clark 2 years ago committed by GitHub
parent d4223f6fd2
commit 494a029a10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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 only 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::<StoreCollection<Wry>>();
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

Loading…
Cancel
Save