From 9144521b901ed58e1417bfd6090f8da2bc5ec173 Mon Sep 17 00:00:00 2001 From: zenitogr <109196423+zenitogr@users.noreply.github.com> Date: Mon, 15 Apr 2024 12:43:48 +0300 Subject: [PATCH] chore(store): update example in README.md (#1176) --- plugins/store/README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/store/README.md b/plugins/store/README.md index 2d47434a..8e04d394 100644 --- a/plugins/store/README.md +++ b/plugins/store/README.md @@ -50,15 +50,20 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: -```javascript +```typescript import { Store } from "tauri-plugin-store-api"; const store = new Store(".settings.dat"); await store.set("some-key", { value: 5 }); -const val = await store.get("some-key"); -assert(val, { value: 5 }); +const val = await store.get<{ value: number }>("some-key"); + +if (val) { + console.log(val); +} else { + console.log("val is null"); +} await store.save(); // this manually saves the store, otherwise the store is only saved when your app is closed ```