wip: gateway

This commit is contained in:
Frank
2025-08-08 13:22:54 -04:00
parent c7bb19ad07
commit 183e0911b7
101 changed files with 9218 additions and 57 deletions

View File

@@ -0,0 +1,26 @@
import { ParentProps, Show, createContext, useContext } from "solid-js"
export function createInitializedContext<
Name extends string,
T extends { ready: boolean },
>(name: Name, cb: () => T) {
const ctx = createContext<T>()
return {
use: () => {
const context = useContext(ctx)
if (!context) throw new Error(`No ${name} context`)
return context
},
provider: (props: ParentProps) => {
const value = cb()
return (
<Show when={value.ready}>
<ctx.Provider value={value} {...props}>
{props.children}
</ctx.Provider>
</Show>
)
},
}
}