@tauri-apps/plugin-store
Classes
Store
A key-value store persisted by the backend layer.
Constructors
constructor()
new Store(path): StoreParameters
| Parameter | Type |
|---|---|
path | string |
Returns
Source: index.ts:20
Properties
| Property | Type |
|---|---|
path | string |
Methods
clear()
clear(): Promise< void >Clears the store, removing all key-value pairs.
Note: To clear the storage and reset it to it’s default value, use reset instead.
Returns
Promise< void >
Source: index.ts:84
delete()
delete(key): Promise< boolean >Removes a key-value pair from the store.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string |
Returns
Promise< boolean >
Source: index.ts:71
entries()
entries<T>(): Promise< [string, T][] >Returns a list of all entries in the store.
Type parameters
| Parameter |
|---|
T |
Returns
Promise< [string, T][] >
Source: index.ts:129
get()
get<T>(key): Promise< null | T >Returns the value for the given key or null the key does not exist.
Type parameters
| Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string |
Returns
Promise< null | T >
Source: index.ts:45
has()
has(key): Promise< boolean >Returns true if the given key exists in the store.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string |
Returns
Promise< boolean >
Source: index.ts:58
keys()
keys(): Promise< string[] >Returns a list of all key in the store.
Returns
Promise< string[] >
Source: index.ts:107
length()
length(): Promise< number >Returns the number of key-value pairs in the store.
Returns
Promise< number >
Source: index.ts:140
load()
load(): Promise< void >Attempts to load the on-disk state at the stores path into memory.
This method is useful if the on-disk state was edited by the user and you want to synchronize the changes.
Note: This method does not emit change events.
Returns
Promise< void >
Source: index.ts:154
onChange()
onChange<T>(cb): Promise< UnlistenFn >Listen to changes on the store.
Since
2.0.0
Type parameters
| Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
cb | (key, value) => void |
Returns
Promise< UnlistenFn >
A promise resolving to a function to unlisten to the event.
Source: index.ts:199
onKeyChange()
onKeyChange<T>(key, cb): Promise< UnlistenFn >Listen to changes on a store key.
Since
2.0.0
Type parameters
| Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | |
cb | (value) => void |
Returns
Promise< UnlistenFn >
A promise resolving to a function to unlisten to the event.
Source: index.ts:181
reset()
reset(): Promise< void >Resets the store to it’s default value.
If no default value has been set, this method behaves identical to clear.
Returns
Promise< void >
Source: index.ts:96
save()
save(): Promise< void >Saves the store to disk at the stores path.
As the store is only persisted to disk before the apps exit, changes might be lost in a crash. This method lets you persist the store to disk whenever you deem necessary.
Returns
Promise< void >
Source: index.ts:167
set()
set(key, value): Promise< void >Inserts a key-value pair into the store.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | |
value | unknown |
Returns
Promise< void >
Source: index.ts:31
values()
values<T>(): Promise< T[] >Returns a list of all values in the store.
Type parameters
| Parameter |
|---|
T |
Returns
Promise< T[] >
Source: index.ts:118
© 2024 Tauri Contributors. CC-BY / MIT