cleanup: use ReactiveState to provide $state with sveltekit (#492)
This commit is contained in:
1 parent
589db4dcc7
commit
7c46e616f8
18 files changed
+168
-168
No files matched your search
@@ -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>
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user