cleanup: use ReactiveState to provide $state with sveltekit (#492)

This commit is contained in:
Xylight authored and GitHub committed 2025-02-17 13:37:37 -08:00
1 parent 589db4dcc7
commit 7c46e616f8
18 files changed
+168 -168

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
// to allow for loading before promises are finished on the client.
import { browser } from '$app/environment'
export const awaitIfServer = async <T>(
promise: Promise<T>,
): Promise<{
data: Promise<T> | T
}> => ({ data: browser ? promise : await promise })
export class ReactiveState<T> {
value = $state<T>()!
constructor(initialValue: T) {
this.value = initialValue as NonNullable<T>
}
}