summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'packages/app/src/utils')
-rw-r--r--packages/app/src/utils/persist.ts16
1 files changed, 14 insertions, 2 deletions
diff --git a/packages/app/src/utils/persist.ts b/packages/app/src/utils/persist.ts
index bee2f3e7d..3dcbeb7d3 100644
--- a/packages/app/src/utils/persist.ts
+++ b/packages/app/src/utils/persist.ts
@@ -5,7 +5,12 @@ import { createResource, type Accessor } from "solid-js"
import type { SetStoreFunction, Store } from "solid-js/store"
type InitType = Promise<string> | string | null
-type PersistedWithReady<T> = [Store<T>, SetStoreFunction<T>, InitType, Accessor<boolean>]
+type PersistedWithReady<T> = [
+ Store<T>,
+ SetStoreFunction<T>,
+ InitType,
+ Accessor<boolean> & { promise: undefined | Promise<any> },
+]
type PersistTarget = {
storage?: string
@@ -460,5 +465,12 @@ export function persisted<T>(
{ initialValue: !isAsync },
)
- return [state, setState, init, () => ready() === true]
+ return [
+ state,
+ setState,
+ init,
+ Object.assign(() => ready() === true, {
+ promise: init instanceof Promise ? init : undefined,
+ }),
+ ]
}