@tauri-apps/plugin-store
Classes
Store
A lazy loaded key-value store persisted by the backend layer.
Extends
Resource
Constructors
new Store()
Parameters
Parameter | Type |
---|---|
rid | number |
path | string |
Returns
Overrides
Resource.constructor
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L41
Accessors
rid
Returns
number
Inherited from
Resource.rid
Source: undefined
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#L108
close()
Destroys and cleans up this resource from memory. You should not call any method on this object anymore and should drop any reference to it.
Returns
Promise
<void
>
Inherited from
Resource.close
Source: undefined
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#L95
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#L145
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#L69
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#L82
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#L127
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#L154
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#L166
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#L207
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#L189
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#L118
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#L177
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#L55
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#L136
Type Aliases
StoreOptions
Options to create a store
Type declaration
Name | Type | Description | Defined in |
---|---|---|---|
autoSave ? | boolean | Auto save on modification with debounce duration in milliseconds | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L22 |
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L18
Functions
createStore()
Parameters
Parameter | Type |
---|---|
path | string |
options ? | StoreOptions |
Returns
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L29
© 2024 Tauri Contributors. CC-BY / MIT