fix(store): fix typings

Co-authored-by: Nelson Truran <nelson@truran.dev>
Co-authored-by: dkzlv <dkzlv@pm.me>
pull/29/head
FabianLars 3 years ago
parent 366e17feae
commit 16c955e8a5
No known key found for this signature in database
GPG Key ID: 3B12BC1DEBF61125

@ -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",

Loading…
Cancel
Save