mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-08-23 19:32:29 +02:00
@@ -42,17 +42,6 @@ export async function getStore(path: string): Promise<Store | undefined> {
|
||||
return await Store.getStore(path)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param path: Path to save the store in `app_data_dir`
|
||||
* @param options: Store configuration options
|
||||
*/
|
||||
export async function getOrCreateStore(
|
||||
path: string,
|
||||
options?: StoreOptions
|
||||
): Promise<Store> {
|
||||
return await Store.getOrCreateStore(path, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* A lazy loaded key-value store persisted by the backend layer.
|
||||
*
|
||||
@@ -67,7 +56,9 @@ export class LazyStore implements IStore {
|
||||
|
||||
private get store(): Promise<Store> {
|
||||
if (!this._store) {
|
||||
this._store = getOrCreateStore(this.path, this.options)
|
||||
this._store = createStore(this.path, this.options).catch(
|
||||
async () => (await getStore(this.path))!
|
||||
)
|
||||
}
|
||||
return this._store
|
||||
}
|
||||
@@ -183,24 +174,6 @@ export class Store extends Resource implements IStore {
|
||||
return resourceId ? new Store(resourceId, path) : undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* @param path: Path to save the store in `app_data_dir`
|
||||
* @param options: Store configuration options
|
||||
*/
|
||||
static async getOrCreateStore(
|
||||
path: string,
|
||||
options?: StoreOptions
|
||||
): Promise<Store> {
|
||||
const resourceId = await invoke<number>(
|
||||
'plugin:store|get_or_create_store',
|
||||
{
|
||||
path,
|
||||
...options
|
||||
}
|
||||
)
|
||||
return new Store(resourceId, path)
|
||||
}
|
||||
|
||||
async set(key: string, value: unknown): Promise<void> {
|
||||
await invoke('plugin:store|set', {
|
||||
rid: this.rid,
|
||||
|
||||
Reference in New Issue
Block a user