mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-22 21:30:44 +02:00
fix(store): fix typings
Co-authored-by: Nelson Truran <nelson@truran.dev> Co-authored-by: dkzlv <dkzlv@pm.me>
This commit is contained in:
co-authored by
Nelson Truran
dkzlv
parent
366e17feae
commit
16c955e8a5
@@ -29,7 +29,7 @@ export class Store {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async set(key: string, value: unknown): Promise<void> {
|
async set(key: string, value: unknown): Promise<void> {
|
||||||
await invoke("plugin:store|set", {
|
return await invoke("plugin:store|set", {
|
||||||
path: this.path,
|
path: this.path,
|
||||||
key,
|
key,
|
||||||
value,
|
value,
|
||||||
@@ -115,7 +115,7 @@ export class Store {
|
|||||||
*
|
*
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async values(): Promise<string[]> {
|
async values<T>(): Promise<T[]> {
|
||||||
return await invoke("plugin:store|values", {
|
return await invoke("plugin:store|values", {
|
||||||
path: this.path,
|
path: this.path,
|
||||||
});
|
});
|
||||||
@@ -137,7 +137,7 @@ export class Store {
|
|||||||
*
|
*
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async length(): Promise<string[]> {
|
async length(): Promise<number> {
|
||||||
return await invoke("plugin:store|length", {
|
return await invoke("plugin:store|length", {
|
||||||
path: this.path,
|
path: this.path,
|
||||||
});
|
});
|
||||||
@@ -160,8 +160,8 @@ export class Store {
|
|||||||
/**
|
/**
|
||||||
* Saves the store to disk at the stores `path`.
|
* Saves the store to disk at the stores `path`.
|
||||||
*
|
*
|
||||||
* As the store is only persistet to disk before the apps exit, changes might be lost in a crash.
|
* As the store is only persisted to disk before the apps exit, changes might be lost in a crash.
|
||||||
* This method let's you persist the store to disk whenever you deem necessary.
|
* This method lets you persist the store to disk whenever you deem necessary.
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async save(): Promise<void> {
|
async save(): Promise<void> {
|
||||||
@@ -196,7 +196,7 @@ export class Store {
|
|||||||
* @returns A promise resolving to a function to unlisten to the event.
|
* @returns A promise resolving to a function to unlisten to the event.
|
||||||
*/
|
*/
|
||||||
async onChange(
|
async onChange(
|
||||||
cb: (key: string, value: unknown) => void
|
cb: (key: string, value: T | null) => void
|
||||||
): Promise<UnlistenFn> {
|
): Promise<UnlistenFn> {
|
||||||
return await appWindow.listen<ChangePayload<unknown>>(
|
return await appWindow.listen<ChangePayload<unknown>>(
|
||||||
"store://change",
|
"store://change",
|
||||||
|
|||||||
Reference in New Issue
Block a user