Skip to content

Commit

Permalink
docs: Fix store example (#2563)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuoJikun authored Aug 20, 2024
1 parent 14dd72d commit 1157a7e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/content/docs/plugin/store.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_store::Builder::default().build())
.setup(|app| {
let stores = app.app_handle().state::<StoreCollection<Wry>>();
let stores = app.handle().try_state::<StoreCollection<Wry>>().ok_or("Store not found")?;
let path = PathBuf::from("store.bin");

with_store(app.app_handle().clone(), stores, path, |store| {
with_store(app.handle().clone(), stores, path, |store| {
// Note that values must be serde_json::Value instances,
// otherwise, they will not be compatible with the JavaScript bindings.
store.insert("some-key".to_string(), json!({ "value": 5 }))?;
Expand Down

0 comments on commit 1157a7e

Please sign in to comment.