@tauri-apps/plugin-store
Classes
Store
A key-value store persisted by the backend layer.
Constructors
new Store()
Parameters
Parameter | Type |
---|---|
path | string |
Returns
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L20
Properties
Property | Type | Defined in |
---|---|---|
path | string | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L19 |
Methods
clear()
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: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L84
delete()
Removes a key-value pair from the store.
Parameters
Parameter | Type | Description |
---|---|---|
key | string |
Returns
Promise
<boolean
>
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L71
entries()
Returns a list of all entries in the store.
Type Parameters
Type Parameter |
---|
T |
Returns
Promise
<[string
, T
][]>
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L129
get()
Returns the value for the given key
or null
the key does not exist.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type | Description |
---|---|---|
key | string |
Returns
Promise
<null
| T
>
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L45
has()
Returns true
if the given key
exists in the store.
Parameters
Parameter | Type | Description |
---|---|---|
key | string |
Returns
Promise
<boolean
>
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L58
keys()
Returns a list of all key in the store.
Returns
Promise
<string
[]>
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L107
length()
Returns the number of key-value pairs in the store.
Returns
Promise
<number
>
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L140
load()
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: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L154
onChange()
Listen to changes on the store.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type | Description |
---|---|---|
cb | (key , value ) => void |
Returns
Promise
<UnlistenFn
>
A promise resolving to a function to unlisten to the event.
Since
2.0.0
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L199
onKeyChange()
Listen to changes on a store key.
Type Parameters
Type 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.
Since
2.0.0
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L181
reset()
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: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L96
save()
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: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L167
set()
Inserts a key-value pair into the store.
Parameters
Parameter | Type | Description |
---|---|---|
key | string | |
value | unknown |
Returns
Promise
<void
>
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L31
values()
Returns a list of all values in the store.
Type Parameters
Type Parameter |
---|
T |
Returns
Promise
<T
[]>
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L118
© 2024 Tauri Contributors. CC-BY / MIT