mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-08-23 19:32:29 +02:00
Add init to lazy store
This commit is contained in:
@@ -54,7 +54,7 @@ export class LazyStore implements IStore {
|
||||
private readonly options?: StoreOptions
|
||||
) {}
|
||||
|
||||
public get store(): Promise<Store> {
|
||||
private get store(): Promise<Store> {
|
||||
if (!this._store) {
|
||||
this._store = createStore(this.path, this.options).catch(
|
||||
async () => (await getStore(this.path))!
|
||||
@@ -63,6 +63,13 @@ export class LazyStore implements IStore {
|
||||
return this._store
|
||||
}
|
||||
|
||||
/**
|
||||
* Init/load the store if it's not already
|
||||
*/
|
||||
async init(): Promise<void> {
|
||||
await this.store
|
||||
}
|
||||
|
||||
async set(key: string, value: unknown): Promise<void> {
|
||||
return (await this.store).set(key, value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user