mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-05-01 12:08:06 +02:00
chore(store): update example in README.md (#1176)
This commit is contained in:
@@ -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
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user